- Timestamp:
- 2012-04-16 12:31:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/JAO/Tero/Pong/Pong/Pong/Pong.cs
r2679 r2694 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; 12 18 13 19 public override void Begin() 14 20 { 15 void LuoKentta(); 16 { 17 pallo = new PhysicsObject(40.0, 40.0); 21 LuoKentta(); 22 AsetaOhjaimet(); 23 AloitaPeli(); 24 } 25 26 void AsetaOhjaimet() 27 { 28 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 29 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös"); 30 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null); 31 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 32 } 33 34 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 35 { 36 maila.Velocity = nopeus; 37 } 38 39 void LuoKentta() 40 { 41 pallo = new PhysicsObject( 40.0, 40.0 ); 18 42 pallo.Shape = Shape.Circle; 19 43 pallo.X = -200.0; 20 44 pallo.Y = 0.0; 21 45 pallo.Restitution = 1.0; 22 Add( pallo);46 Add( pallo ); 23 47 24 PhysicsObject maila = PhysicsObject.CreateStaticObject( 20.0, 100.0 ); 25 maila.Shape = Shape.Rectangle; 26 maila.X = Level.Left + 20.0; 27 maila.Y = 0.0; 28 maila.Restitution = 1.0; 29 Add( maila ); 48 LuoMaila(Level.Left + 20.0, 0.0); 49 LuoMaila(Level.Right - 20.0, 0.0); 30 50 31 Level.CreateBorders( 1.0, false);51 Level.CreateBorders( 1.0, false ); 32 52 Level.BackgroundColor = Color.Black; 53 54 33 55 34 56 Camera.ZoomToLevel(); 35 57 } 36 58 59 void AloitaPeli() 60 { 61 Vector impulssi = new Vector( 500.0, 0.0 ); 62 pallo.Hit( impulssi ); 37 63 38 39 40 41 Vector impulssi = new Vector(500.0, 0.0);42 pallo.Hit(impulssi);43 64 44 65 45 66 67 } 46 68 47 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 48 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 69 PhysicsObject LuoMaila(double x, double y) 70 { 71 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 72 maila.Shape = Shape.Rectangle; 73 maila.X = x; 74 maila.Y = y; 75 maila.Restitution = 1.0; 76 Add(maila); 49 77 78 return maila; 79 } 50 80 } 51 52
Note: See TracChangeset
for help on using the changeset viewer.