Changeset 7708 for 2016/27/LeeviT/pong/pong/pong/pong.cs
- Timestamp:
- 2016-07-04 14:52:48 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/27/LeeviT/pong/pong/pong/pong.cs
r7686 r7708 13 13 public override void Begin() 14 14 { 15 16 15 17 LuoKentta(); 16 Vector impulssi = new Vector(500.0, 0.0); 17 pallo.Hit(impulssi); 18 AloitaPeli(); 19 AsetaOhjaimet(); 20 { 21 18 22 19 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 20 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 23 24 } 25 26 21 27 } 28 void LuoMaila(double x, double y) 29 { 30 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 31 maila.Shape = Shape.Rectangle; 32 maila.X = x; 33 maila.Y = y; 34 maila.Restitution = 1.0; 35 Add(maila); 22 36 37 } 23 38 void LuoKentta() 24 39 { 25 PhysicsObjectpallo = new PhysicsObject(40.0, 40.0);40 pallo = new PhysicsObject(40.0, 40.0); 26 41 pallo.Shape = Shape.Circle; 27 42 pallo.X = -200.0; … … 30 45 Add(pallo); 31 46 32 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 33 maila.Shape = PhysicsObject.Rectangle; 34 maila.X = Level.Left + 20.0; 35 maila.Y = 0.0; 36 maila.Restitution = 1.0; 37 Add(maila); 38 47 LuoMaila(Level.Left + 20.0, 0.0); 48 LuoMaila(Level.Right - 20.0, 0.0); 39 49 40 50 Level.CreateBorders(1.0, false); … … 44 54 45 55 } 56 void AloitaPeli(){ 57 Vector impulssi = new Vector(500.0, 0.0); 58 pallo.Hit(impulssi); 46 59 60 } 61 void AsetaOhjaimet() 62 { 63 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMaila1Ylos, "Pelaaja 1: Liikuta mailaa ylös"); 64 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila1, null); 65 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 66 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 67 } 68 void AsetaNopeus(PhysicsObject maila,Vector nopeus) 69 { 70 maila.Velocity = nopeus) 71 } 47 72 }
Note: See TracChangeset
for help on using the changeset viewer.