- Timestamp:
- 2015-07-01 14:02:38 (8 years ago)
- Location:
- 2015/27/VilleHa
- Files:
-
- 41 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/VilleHa/Pong/Pong/Pong/Pong.cs
r6493 r6673 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 13 11 14 PhysicsObject pallo; 15 16 PhysicsObject maila1; 17 PhysicsObject maila2; 18 12 19 public override void Begin() 13 20 { … … 15 22 16 23 LuoKentta(); 24 AsetaOhjaimet(); 17 25 AloitaPeli(); 18 26 … … 22 30 23 31 24 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");32 25 33 } 26 34 void LuoKentta() … … 33 41 pallo.Restitution = 1.0; 34 42 35 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 36 maila.Shape = Shape.Rectangle; 37 maila.X = Level.Left + 20.0; 38 maila.Y = 0.0; 39 maila.Restitution = 1.0; 40 Add(maila); 43 maila1 = LuoMaila (Level.Left + 20.0, 0.0); 44 maila2 = LuoMaila (Level.Right - 20.0, 0.0); 45 46 41 47 42 48 Level.CreateBorders(0.85, false); 43 49 Level.Background.Color = Color.Black; 44 Camera.ZoomToLevel(); 50 51 Camera.ZoomToLevel(); 45 52 } 46 53 void AloitaPeli() … … 48 55 pallo.Hit(impulssi); 49 56 } 50 void LuoMaila(double x, double y) 51 { PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 52 maila.Shape = Shape.Rectangle; 53 maila.X = x; 54 maila.Y = y; 55 maila.Restitution = 1.0; 56 Add(maila); 57 PhysicsObject LuoMaila(double x, double y) 58 { 59 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 60 61 maila.Shape = Shape.Rectangle; 62 maila.X = x; 63 maila.Y = y; 64 maila.Restitution = 1.0; 65 Add(maila); 66 return maila; 57 67 } 68 void AsetaOhjaimet() 69 { 70 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös",maila1, nopeusYlos); 71 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 72 Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, " Pelaaja 1 liikuta mailaa alas", maila1, nopeusAlas); 73 Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 74 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 75 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 76 Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 77 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 78 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 79 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 80 81 82 83 } 84 85 void AsetaNopeus(PhysicsObject maila, Vector nopeus); 86 87 88 89 } 90 91 92 58 93 } 59 94
Note: See TracChangeset
for help on using the changeset viewer.