Changeset 5526 for 2014/30/JouniP/Pong/Pong/Pong/Pong.cs
- Timestamp:
- 2014-07-22 09:36:37 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/JouniP/Pong/Pong/Pong/Pong.cs
r5466 r5526 9 9 public class Pong : PhysicsGame 10 10 { 11 public override void Begin() 12 { 13 // TODO: Kirjoita ohjelmakoodisi tähän 14 PhysicsObject pallo = new PhysicsObject(40.0, 40.0); 15 pallo.Shape = Shape.Circle; 16 pallo.X = 100.0; 17 pallo.Y = 100.0; 18 pallo.Color = Color.HotPink; 19 Add(pallo); 11 PhysicsObject pallo; 20 12 13 public override void Begin() 14 { 15 LuoKentta(); 16 AloitaPeli(); 21 17 22 // Lisätään näppäintenkuuntelijat: 23 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); // esc-näppäin 24 } 18 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 19 } 20 21 void LuoKentta() 22 { 23 LuoPallo(); 24 25 LuoMaila(Level.Left + 20.0, Level.Top - 100.0); 26 LuoMaila(Level.Right - 20.0, Level.Bottom + 100.0); 27 28 Level.CreateBorders(1.0, false); 29 Level.Background.Color = Color.Black; 30 31 Camera.ZoomToLevel(); 32 } 33 34 void LuoPallo() 35 { 36 pallo = new PhysicsObject(40.0, 40.0); 37 pallo.Shape = Shape.Circle; 38 pallo.X = -200.0; 39 pallo.Y = 0.0; 40 pallo.Restitution = 1.0; 41 Add(pallo); 42 } 43 44 void LuoMaila(double sijaintiVaakasuunnassa, double sijaintiPystysuunnassa) 45 { 46 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 47 maila.Shape = Shape.Rectangle; 48 maila.X = sijaintiVaakasuunnassa; 49 maila.Y = sijaintiPystysuunnassa; 50 maila.Restitution = 1.0; 51 Add(maila); 52 } 53 54 void AloitaPeli() 55 { 56 Vector impulssi = new Vector(500.0, 0.0); 57 pallo.Hit(impulssi); 58 } 59 25 60 }
Note: See TracChangeset
for help on using the changeset viewer.