Changeset 7489
- Timestamp:
- 2016-06-22 15:55:11 (7 years ago)
- Location:
- 2016/25/AaroV/Tankz
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/25/AaroV/Tankz/Tankz/Tankz/Tankz.cs
r7477 r7489 14 14 public override void Begin() 15 15 { 16 tankki = Luotankki(-300, -100);17 tankki2 = Luotankki(300, -100);18 tankki3 = Luotankki(0, -100);16 tankki = Luotankki(-300,0,2); 17 tankki2 = Luotankki(300,0,3); 18 tankki3 = Luotankki(0, 0,4); 19 19 Surface maasto = Surface.CreateBottom(Level, 50, 200, 20, 50); 20 20 Add(maasto); 21 maasto.Restitution = 0.1; 21 22 Gravity = new Vector(0, -600); 22 23 Keyboard.Listen(Key.Down, ButtonState.Down, KaannaTykkia,null, tankki, -1.0); … … 30 31 Keyboard.Listen(Key.LeftShift, ButtonState.Released, Ammu, null, tankki3); 31 32 32 33 33 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 34 34 Level.Background.Color = Color.MediumTurquoise; … … 37 37 } 38 38 void KaannaTykkia(Tankki tankki, Double kulma) 39 { 39 { 40 40 tankki.kulma += kulma; 41 41 }void Ammu(Tankki tankki) { 42 42 if (tankki.ElamaLaskuri.Value == 0) return; 43 43 Vector suunta = Vector.FromLengthAndAngle(tankki.tykki.Width, tankki.tykki.AbsoluteAngle); 44 44 PhysicsObject ammus = new PhysicsObject(10, 2); … … 47 47 ammus.Angle = tankki.tykki.AbsoluteAngle ; 48 48 Add(ammus); 49 ammus.Velocity = Vector.FromLengthAndAngle(800, tankki.tykki.AbsoluteAngle ) ; 49 ammus.Tag = "ammus"; 50 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 51 ammus.LifetimeLeft = TimeSpan.FromSeconds(4); 52 ammus.Velocity = Vector.FromLengthAndAngle(850, tankki.tykki.AbsoluteAngle ) ; 50 53 } 51 Tankki Luotankki(Double X, Double Y ) {54 Tankki Luotankki(Double X, Double Y,int tormausryhma) { 52 55 Tankki tankki = new Tankki(30, 30); 53 tankki.CollisionIgnoreGroup = 2;56 tankki.CollisionIgnoreGroup = tormausryhma; 54 57 Add(tankki); 55 58 tankki.X = X; 56 59 tankki.Y = Y; 57 60 tankki.Mass = 5; 61 62 63 AddCollisionHandler(tankki, "ammus", tankkiinosui); 58 64 return tankki; 59 65 } 60 66 61 62 63 64 67 void tankkiinosui(PhysicsObject tankki,PhysicsObject ammus) 68 { 69 Tankki pelaaja = (Tankki)tankki; 70 pelaaja.ElamaLaskuri.Value--; 71 72 } 65 73 } 66 67 68 74 69 75 class Tankki : PhysicsObject … … 81 87 IsUpdated = true; 82 88 } 83 84 89 85 90 public override void Update(Time time) … … 90 95 base.Update(time); 91 96 92 93 97 } 94 98 }
Note: See TracChangeset
for help on using the changeset viewer.