Changeset 2372 for 2011/26/JimiL/Pelit/pelit22/world of Chuckland fix fix/world of Chuckland fix fix/Peli.cs
- Timestamp:
- 2011-06-30 14:57:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/JimiL/Pelit/pelit22/world of Chuckland fix fix/world of Chuckland fix fix/Peli.cs
r2365 r2372 7 7 using Jypeli.Widgets; 8 8 9 10 11 12 13 9 public class Peli : PhysicsGame 10 { 11 const double nopeus = 300; 12 const double hyppyNopeus = 1000; 13 // const double InventaarioX = Screen.Left 14 14 15 {16 const double nopeus = 500;17 const double hyppyNopeus = 1000;18 15 const int RUUDUN_KOKO = 40; 19 16 20 21 22 23 GameObject heppu;17 PlatformCharacter pelaaja1; 18 19 20 PhysicsObject heppu; 24 21 Image paikallaanvasemmalle1 = LoadImage("heppuleft1"); 25 22 Image paikallaanoikelle1 = LoadImage("heppu"); … … 30 27 Image paikallaanvasemmalle = LoadImage("hahmo"); 31 28 Image paikallaanoikelle = LoadImage("hahmo"); 32 33 Image[] kavelyoikelle = LoadImages("hahmoright1", "hahmoright2");29 30 Image[] kavelyoikelle = LoadImages("hahmoright1", "hahmoright2"); 34 31 Image[] kavelyvasemmalle; 35 32 Image pelaajanKuva = LoadImage("hahmo"); … … 47 44 Image ruohokuva = LoadImage("ruoho"); 48 45 Image koivukuva = LoadImage("koivu"); 49 50 46 Widget Inventory; 51 47 52 48 SoundEffect maaliAani = LoadSoundEffect("maali"); 49 50 List<PhysicsObject> keratytTavarat = new List<PhysicsObject>(); 53 51 54 52 public override void Begin() … … 60 58 kavelyoikelle1 = Image.Mirror(kavelyvasemmalle1); 61 59 62 63 64 65 66 67 60 Gravity = new Vector(0, -1000); 68 69 70 71 61 72 62 luoKentta(); … … 93 83 kentta['='] = lisaaruoho; 94 84 kentta[')'] = lisaakoivu; 95 96 97 98 85 kentta['x'] = lisaaKerattava; 99 86 100 87 kentta.Insert(50, 50); 101 88 Level.CreateBorders(); 102 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 103 } 104 RandomMoverBrain Satunnaisaivot = new RandomMoverBrain(10000); 105 106 107 89 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 90 } 91 RandomMoverBrain Satunnaisaivot = new RandomMoverBrain(12000); 92 93 94 PhysicsObject lisaaKerattava() 95 { 96 PhysicsObject kerattava = new PhysicsObject(20, 20); 97 kerattava.Tag = "kerattava1"; 98 return kerattava; 99 } 108 100 109 101 PhysicsObject lisaakoivu() … … 112 104 koivu.Image = koivukuva; 113 105 koivu.Tag = "koivu"; 114 115 Add(koivu);116 106 return koivu; 117 107 } … … 205 195 206 196 heppu.Brain = Satunnaisaivot; 207 Satunnaisaivot.ChangeMovementSeconds = 5;197 Satunnaisaivot.ChangeMovementSeconds = RandomGen.NextDouble(2.3, 5.5); 208 198 heppu.Tag = "heppu"; 209 199 heppu.Image = heppukuva; … … 222 212 pelaaja1.Image = pelaajanKuva; 223 213 pelaaja1.Tag = "pelaaja1"; 224 225 226 214 215 216 227 217 pelaaja1.LeftIdleAnimation = new Animation(paikallaanvasemmalle); 228 218 pelaaja1.RightIdleAnimation = new Animation(paikallaanoikelle); … … 234 224 return pelaaja1; 235 225 236 237 238 239 } 240 241 242 226 227 228 229 } 230 231 232 243 233 244 234 void lisaaNappaimet() … … 246 236 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 247 237 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 248 238 Keyboard.Listen(Key.E, ButtonState.Pressed, avaainventory, "avaa inventoryn"); 239 Keyboard.Listen(Key.E, ButtonState.Released, sulkeeinventory, "sulkee inventoryn"); 249 240 250 241 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 268 259 hahmo.Jump(nopeus); 269 260 } 270 void osupelaajaan(PhysicsObject pelaaja, PhysicsObject heppu) 261 262 263 void osupelaajaan(PhysicsObject pelaaja, PhysicsObject kohde) 271 264 { 272 265 if (pelaaja.Tag.ToString() == "pelaaja1") 273 274 266 { 275 if ( heppu.Tag.ToString() == "heppu")267 if (kohde.Tag.ToString() == "heppu") 276 268 { 277 278 269 maaliAani.Play(); 279 270 MessageDisplay.Add("Die"); 280 271 pelaaja.Destroy(); 281 282 283 284 285 272 } 273 274 if (kohde.Tag.ToString() == "kerattava1") 275 { 276 keratytTavarat.Add(kohde); 277 kohde.Destroy(); 286 278 } 287 279 } 288 280 } 289 void OsuEsineeseen(PlatformCharacter pelaaja1, PhysicsObject kohde) 290 { 291 292 293 294 } 295 296 297 298 } 299 281 void AvaaInventory() 282 { 283 Inventory = new Widget(253.0, 388.0); 284 Inventory.X = Screen.LeftSafe + 1000; 285 Inventory.Y = Screen.TopSafe - 400; 286 287 Inventory.Image = LoadImage("inventory"); 288 Add(Inventory); 289 290 for (int i = 0; i < keratytTavarat.Count; i++) 291 { 292 if (keratytTavarat[i].Tag.ToString() == "kerattava1") 293 { 294 Widget aseWidget = new Widget(35, 35); 295 aseWidget.X = Screen.LeftSafe + 1000; 296 aseWidget.Y = Screen.TopSafe - 400; 297 Add(aseWidget); 298 } 299 } 300 301 } 302 303 304 void avaainventory() 305 { 306 AvaaInventory(); 307 308 } 309 void sulkeeinventory() 310 { 311 Inventory.Destroy(); 312 313 } 314 } 315
Note: See TracChangeset
for help on using the changeset viewer.