Changeset 536
- Timestamp:
- 2010-06-08 11:26:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/jealmaki/poing/jealmaki Peli.cs
r520 r536 9 9 { 10 10 PhysicsObject pallo; 11 11 PhysicsObject maila1; 12 PhysicsObject maila2; 12 13 protected override void Begin() 13 14 { 14 15 LuoKentta(); 15 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");16 AsetaOhjaimet(); 16 17 AloitaPeli(); 17 18 Vector impulssi = new Vector(300.0, 1.0); … … 30 31 pallo.Hit(impulssi); 31 32 32 LuoMaila(Level.Left + 20.0, 0.0);33 LuoMaila(Level.Right - 20.0, 0.0);33 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 34 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 34 35 35 36 Level.CreateBorders(1.0, false); … … 54 55 return maila; 55 56 } 57 void LiikutaMailaaYlos(PhysicsObject maila) 58 { 59 if (maila.Y >= Level.Top) 60 { 61 maila.Velocity = Vector.Zero; 62 return; 63 } 64 65 Vector nopeus = new Vector(0, 200); 66 maila.Velocity = nopeus; 67 68 } 69 70 void PysaytaMaila(PhysicsObject maila) 71 { 72 maila.Velocity = Vector.Zero; 73 } 74 75 void LiikutaMailaaAlas(PhysicsObject maila) 76 { 77 { 78 79 Vector nopeus = new Vector(0, -200); 80 maila.Velocity = nopeus; 81 82 } 83 } 56 84 void AsetaOhjaimet() 57 85 { 58 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 86 87 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös", maila1); 88 Keyboard.Listen(Key.W, ButtonState.Released, PysaytaMaila, null, maila1); 89 Keyboard.Listen(Key.S, ButtonState.Down, LiikutaMailaaAlas, "Pelaaja 1: Liikuta mailaa alas", maila1); 90 Keyboard.Listen(Key.S, ButtonState.Released, PysaytaMaila, null, maila1); 91 92 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 2: Liikuta mailaa ylös", maila2); 93 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMaila, null, maila2); 94 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaMailaaAlas, "Pelaaja 2: Liikuta mailaa alas", maila2); 95 Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaMaila, null, maila2); 96 97 Keyboard.Listen(Key.F1, ButtonState.Down, ShowControlHelp, "Näytä ohjeet"); 98 Keyboard.Listen(Key.Escape, ButtonState.Down, Exit, "Poistu"); 99 59 100 } 60 61 101 62 102 } 63 103
Note: See TracChangeset
for help on using the changeset viewer.