Changeset 4046 for 2013/24/BenjaminT/Pong/Pong/Pong/Pong.cs
- Timestamp:
- 2013-06-10 14:47:53 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/24/BenjaminT/Pong/Pong/Pong/Pong.cs
r4043 r4046 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlos = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 13 14 15 16 17 PhysicsObject pallo; 18 19 PhysicsObject maila1; 20 PhysicsObject maila2; 21 11 22 public override void Begin() 12 23 { 13 PhysicsObject pallo = new PhysicsObject(80.0, 80.0); 24 LuoKentta(); 25 Vector impulssi = new Vector(500.0, 0.0); 26 pallo.Hit(impulssi); 27 28 AsetaOhjaimet(); 29 30 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 31 } 32 33 void LuoKentta() 34 { 35 pallo = new PhysicsObject(40.0, 40.0); 14 36 pallo.Shape = Shape.Circle; 15 Add(pallo);16 37 pallo.X = -200.0; 17 38 pallo.Y = 0.0; 39 pallo.Restitution = 1.0; 40 Add(pallo); 41 42 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 43 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 44 45 46 47 48 49 50 51 52 53 54 Level.CreateBorders(1.0, false); 55 Level.BackgroundColor = Color.Black; 56 57 58 59 Camera.ZoomToLevel(); 60 } 61 62 63 64 65 66 67 68 void AloitaPeli() 69 { 18 70 Vector impulssi = new Vector(500.0, 0.0); 19 71 pallo.Hit(impulssi); 20 Level.CreateBorders(1.0, false); 21 pallo.Restitution = 1.0; 22 Level.BackgroundColor = Color.Black; 72 23 73 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 24 74 } 25 } 75 76 77 PhysicsObject LuoMaila(double x, double y) 78 { 79 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 80 maila.Shape = Shape.Rectangle; 81 maila.X = x; 82 maila.Y = y; 83 maila.Restitution = 1.0; 84 Add(maila); 85 return maila; 86 87 88 89 } 90 91 92 void AsetaOhjaimet() 93 { 94 95 96 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMaila1Ylos, "Pelaaja 1: Liikuta maila ylös"); 97 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila1, null); 98 99 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 100 } 101 102 voida AsetaNopeus(PhysicsObject maila, Vector nopeus) 103 { 104 105 maila.Velocity = nopeus;
Note: See TracChangeset
for help on using the changeset viewer.