- Timestamp:
- 2013-06-06 15:06:52 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/23/LeoS/Tasohyppelypeli2.cs
r3992 r3995 31 31 32 32 public Boolean tpmittari = true; 33 List<PlatformCharacter> kytat = new List<PlatformCharacter>(); 33 34 PlatformCharacter homo; 34 35 Image olionkuva = LoadImage("hahmo"); 35 36 Image olionkuva2 = LoadImage("poliisi"); 36 Image hahmonkuva = LoadImage("iron"); 37 37 Image olionkuva3 = LoadImage("Copcar"); 38 38 IntMeter elamat; … … 43 43 { 44 44 LuoKentta(); 45 Gravity = new Vector(0, - 1000);45 Gravity = new Vector(0, -2000); 46 46 elamat = new IntMeter(10, 0, 10); 47 47 elamat.LowerLimit += delegate { homo.Destroy(); }; … … 76 76 AddCollisionHandler(homo, "ammus", Hittipointsi); 77 77 AddCollisionHandler(homo, "potion", OtaPotion); 78 AddCollisionHandler<PlatformCharacter, Kytta>(homo, Hyokkaa); 78 79 Mouse.IsCursorVisible = true; 79 80 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "A.C.A.B"); //näppäinkomennot 80 Keyboard.Listen(Key.Left, ButtonState.Down, Kavele, null, (-100 0.0)); //näppäinkomennot81 Keyboard.Listen(Key.Right, ButtonState.Down, Kavele, null, (100 0.0)); //näppäinkomennot //näppäinkomennot82 Keyboard.Listen(Key.A, ButtonState.Down, Ammu, null, homo);81 Keyboard.Listen(Key.Left, ButtonState.Down, Kavele, null, (-100.0)); //näppäinkomennot 82 Keyboard.Listen(Key.Right, ButtonState.Down, Kavele, null, (100.0)); //näppäinkomennot //näppäinkomennot 83 //Keyboard.Listen(Key.A, ButtonState.Down, hyokkaa, null, homo); 83 84 Keyboard.Listen(Key.Z, ButtonState.Released, JuoPotion, null); 84 85 Keyboard.Listen(Key.E, ButtonState.Down, Pusauta, null); 85 86 Keyboard.Listen(Key.Q, ButtonState.Down, Jatka, null); 86 87 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, gayteleport, null); 87 Camera.ZoomToLevel(); 88 89 } 90 91 88 Camera.Follow(homo); 89 90 } 91 92 void Hyokkaa(PlatformCharacter p, Kytta k) 93 { 94 k.Destroy(); 95 } 96 97 92 98 void gayteleport() 93 99 { 94 100 if (tpmittari == true) 95 101 { 96 homo.Position = Mouse.PositionOnWorld; 102 Vector telePoint = Mouse.PositionOnWorld; 103 for (int i = 0; i < kytat.Count; i++) 104 { 105 if (Vector.Distance(kytat[i].Position, telePoint) <= 300) 106 return; 107 } 108 109 homo.Position = telePoint; 97 110 tpmittari = false; 98 111 tpajastin.Reset(); … … 240 253 Kytta kytta = new Kytta(93, 150, 2); 241 254 kytta.Position = paikka; 242 kytta.Image = olionkuva2;255 kytta.Image = hahmonkuva; 243 256 kytta.Tag = "kytta"; 244 257 … … 257 270 Timer ajastin = new Timer(); 258 271 ajastin.Interval = 1.0; 259 ajastin.Timeout += delegate { TarkistaAmpuuko(kytta Ase); };272 ajastin.Timeout += delegate { TarkistaAmpuuko(kytta); }; 260 273 ajastin.Start(); 261 262 kyt ta.Destroyed += ajastin.Stop;263 } 264 265 266 void TarkistaAmpuuko( AssaultRifle ase)267 { 268 if (Vector.Distance( ase.Position, homo.Position) <= 100)274 kytta.Destroyed += delegate { ajastin.Stop(); kytat.Remove(kytta); }; 275 kytat.Add(kytta); 276 } 277 278 279 void TarkistaAmpuuko(Kytta kytta) 280 { 281 if (Vector.Distance(kytta.Position, homo.Position) <= 1000) 269 282 { 270 283 // ase.Angle = new Vector(ase.Position.X - Snoopdogg.Position.X, ase.Position.Y - Snoopdogg.Position.Y).Angle; 271 PhysicsObject ammus = ase.Shoot(); 284 PhysicsObject ammus = kytta.Weapon.Shoot(); 285 ammus.Size *= 3; 272 286 ammus.LifetimeLeft = TimeSpan.FromSeconds(1); 273 287 ammus.Tag = "ammus"; … … 283 297 Add(copcar); 284 298 } 285 286 287 288 289 290 291 292 293 299 } 294 300
Note: See TracChangeset
for help on using the changeset viewer.