- Timestamp:
- 2014-07-24 11:20:58 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/EevaS/Zombie attack!/Zombie attack!/Zombie attack!/Zombie_attack_.cs
r5596 r5621 7 7 using Jypeli.Widgets; 8 8 9 public class Zombie_attack_ : Game9 public class Zombie_attack_ : PhysicsGame 10 10 { 11 11 Image pelaajakuva = LoadImage("Pelaaja"); … … 18 18 19 19 private Image tahdenkuva; 20 private object zombi; 20 21 21 22 22 23 public override void Begin() … … 36 37 37 38 ruudut.Execute(20, 20); 39 40 Camera.ZoomToLevel(); 38 41 } 39 42 40 43 void LuoPelaaja(Vector paikka, double leveys, double korkeus) 41 44 { 42 pelaaja = new PhysicsObject(1 0, 10);45 pelaaja = new PhysicsObject(15, 20); 43 46 pelaaja.Position = paikka; 44 47 pelaaja.Image = pelaajakuva; 45 48 Add(pelaaja); 49 pelaaja.CanRotate = false; 50 pelaaja.Restitution = 0.0; 51 52 Vector pelaajanSuunta = Vector.FromLengthAndAngle(500.0, pelaaja.Angle); 53 pelaaja.Push(pelaajanSuunta); 54 } 55 56 void LuoVihollinen(Vector paikka, double leveys, double korkeus) 57 { 58 PhysicsObject zombi = new PhysicsObject(15, 20); 59 zombi.Position = paikka; 60 zombi.Tag = "pahis"; 61 Add(zombi); 46 62 } 47 63 … … 53 69 taso.CollisionIgnoreGroup = 1; 54 70 Add(taso); 71 Level.Background.Color = Color.Black; 55 72 } 56 73 … … 65 82 } 66 83 67 void LuoVihollinen(Vector paikka, double leveys, double korkeus)68 {69 PhysicsObject zombi = new PhysicsObject(20, 40);70 zombi.Position = paikka;71 zombi.Tag = "pahis";72 Add(zombi);73 }74 75 84 void AsetaOhjaimet() 76 85 { 77 86 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 78 79 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Liikuta hahmoa ylös", pelaajakuva, nopeusYlos); 80 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null 87 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 88 89 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, "Liikuta hahmoa ylös", pelaaja, nopeusYlos); 90 Keyboard.Listen(Key.Up, ButtonState.Released, LiikutaPelaajaa, null, pelaaja, Vector.Zero); 91 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, "Liikuta hahmoa alas", pelaaja, nopeusAlas); 92 Keyboard.Listen(Key.Down, ButtonState.Released, LiikutaPelaajaa, null, pelaaja, Vector.Zero); 93 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, "Liikuta hahmoa vasemmalle", pelaaja, nopeusVasemmalle); 94 Keyboard.Listen(Key.Left, ButtonState.Released, LiikutaPelaajaa, null, pelaaja, Vector.Zero); 95 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, "Liikuta hahmoa oikealle", pelaaja, nopeusOikealle); 96 Keyboard.Listen(Key.Right, ButtonState.Released, LiikutaPelaajaa, null, pelaaja, Vector.Zero); 81 97 } 82 98 83 99 void LiikutaPelaajaa(PhysicsObject pelaaja, Vector suunta) 100 { 101 pelaaja.Velocity = suunta; 102 } 84 103 }
Note: See TracChangeset
for help on using the changeset viewer.