Changeset 7458
- Timestamp:
- 2016-06-19 15:46:06 (6 years ago)
- Location:
- 2016/25/MatiasA/Pong 03
- Files:
-
- 9 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/25/MatiasA/Pong 03/Pong 03/Pong_03/Pong_03.cs
r7455 r7458 9 9 public class Pong_03 : PhysicsGame 10 10 { 11 PhysicsObject pallo; 12 Vector nopeusYlos = new Vector(0, 200); 13 Vector nopeusalas = new Vector(0, -200); 14 const double PALLON_MIN_NOPEUS = 10000; 15 PhysicsObject maila1; 16 PhysicsObject maila2; 17 11 18 public override void Begin() 12 19 { … … 14 21 15 22 16 17 23 24 25 LuoKentta(); 26 AsetaOhjaimet(); 27 Aloitapeli(); 18 28 19 29 20 30 31 Vector impulssi = new Vector(500.0, 0.0); pallo.Hit(impulssi); 21 32 22 Vector impulssi = new Vector(500.0, 0.0); pallo.Hit(impulssi);23 33 Level.CreateBorders(1.0, false); 24 34 25 35 26 36 Level.Background.CreateGradient(Color.Black, Color.Gold); … … 43 53 pallo.Restitution = 1.0; 44 54 45 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);46 maila.Shape = Shape.Rectangle;47 maila.X = Level.Left + 20.0s48 55 56 LuoMaila(Level.Left + 20.0, 0.0); 57 LuoMaila(Level.Right - 20.0, 0.0); 58 59 60 Level.CreateBorders(1.0, false); 61 Level.Background.Color = Color.Black; 49 62 } 50 63 64 void Aloitapeli() 65 { 66 Vector impulssi = new Vector(500.0, 0.0); 67 pallo.Hit(impulssi); 68 } 69 70 71 72 73 void AsetaOhjaimet() 74 { 75 Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 76 Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 77 78 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 79 } 51 80 52 81 82 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 83 { 84 maila.Velocity = nopeus; 53 85 } 86 87 PhysicsObject LuoMaila (double x, double y) 88 { 89 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 120.0); 90 maila.Shape = Shape.Rectangle; 91 maila.X = x; 92 maila.Y = y; 93 maila.Restitution = 1.0; 94 Add(maila); 95 return maila; 96 } 97 98 99 100 101 102 103 104 } 105 106
Note: See TracChangeset
for help on using the changeset viewer.