Changeset 8704
- Timestamp:
- 2017-06-15 11:58:00 (4 years ago)
- Location:
- 2017/24/SebastianH/JumpingAdventure
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/24/SebastianH/JumpingAdventure/JumpingAdventure/JumpingAdventure/JumpingAdventure.cs
r8676 r8704 11 11 PhysicsObject spaceship; 12 12 PhysicsObject ufo; 13 IntMeter elinvoimaLaskuri; 13 14 public override void Begin() 14 15 { 15 16 Gravity = new Vector(0.0, -800.0); 17 18 LuoVihollinen(new Vector(100.0, 100.0), 80.0, 700.0); 19 LuoElinvoimalaskuri(); 16 20 17 21 spaceship = new PhysicsObject(30, 40, Shape.Star); … … 20 24 spaceship.Color = Color.Fuchsia; 21 25 spaceship.CanRotate = false; 26 AddCollisionHandler(spaceship, "pahis", PelaajaOsuu); 22 27 Add(spaceship); 23 28 24 ufo = new PhysicsObject(40, 20, Shape.Ellipse); 25 ufo.X = 300.0; 26 ufo.Y = -150.0; 27 ufo.Color = Color.Red; 28 Add(ufo); 29 29 30 30 31 Level.Background.CreateStars(100000); … … 38 39 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 2000)); 39 40 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaPelaaja, null, new Vector(0, 0)); 40 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -1000));41 Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaPelaaja, null, new Vector(0, 0));42 41 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 43 42 } … … 50 49 spaceship.Velocity = Vector.Zero; 51 50 } 51 52 void LuoVihollinen(Vector paikka, double leveys, double korkeus) 53 { 54 ufo = new PhysicsObject(leveys, korkeus, Shape.Ellipse); 55 ufo.Position = paikka; 56 ufo.Tag = "pahis"; 57 ufo.Color = Color.Red; 58 Add(ufo); 59 } 60 61 void LuoElinvoimalaskuri() 62 { 63 elinvoimaLaskuri = new IntMeter(3000); 64 65 Label elinvoimaNaytto = new Label(); 66 elinvoimaNaytto.X = Screen.Left + 100; 67 elinvoimaNaytto.Y = Screen.Top - 100; 68 elinvoimaNaytto.TextColor = Color.White; 69 elinvoimaNaytto.Color = Color.Black; 70 71 elinvoimaNaytto.BindTo(elinvoimaLaskuri); 72 Add(elinvoimaNaytto); 73 } 74 75 void PelaajaOsuu(PhysicsObject spaceship, PhysicsObject kohde) 76 { 77 elinvoimaLaskuri.Value--; 78 79 if (elinvoimaLaskuri <= 0) 80 spaceship.Destroy(); 81 } 82 52 83 }
Note: See TracChangeset
for help on using the changeset viewer.