- Timestamp:
- 2015-07-21 14:09:59 (8 years ago)
- Location:
- 2015/30/ValtteriT/Pong
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/30/ValtteriT/Pong/Pong/Pong/Pong.cs
r6843 r6860 15 15 PhysicsObject maila1; 16 16 PhysicsObject maila2; 17 PhysicsObject oikeaReuna; 18 PhysicsObject vasenReuna; 17 19 18 20 IntMeter pelaajan1Pisteet; … … 21 23 public override void Begin() 22 24 { 25 ClearAll(); 23 26 LuoKentta(); 24 27 AsetaOhjaimet(); … … 37 40 pallo = new PhysicsObject(40.0, 40.0); 38 41 pallo.Shape = Shape.Circle; 39 42 pallo.KineticFriction = 0.0; 43 pallo.MomentOfInertia = Double.PositiveInfinity; 40 44 pallo.X = 200.0; 41 45 pallo.Y = 0.0; 42 46 pallo.Restitution = 1.0; 43 47 Add(pallo); 48 AddCollisionHandler(pallo, KasittelePallonTormays); 44 49 45 50 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 46 51 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 47 52 48 Level.CreateBorders(1.0, false); 53 vasenReuna = Level.CreateLeftBorder(); 54 vasenReuna.Restitution = 1.0; 55 vasenReuna.IsVisible = false; 56 oikeaReuna = Level.CreateRightBorder(); 57 oikeaReuna.Restitution = 1.0; 58 oikeaReuna.IsVisible = false; 59 PhysicsObject ylaReuna = Level.CreateTopBorder(); 60 ylaReuna.Restitution = 1.0; 61 ylaReuna.IsVisible = false; 62 PhysicsObject alaReuna = Level.CreateBottomBorder(); 63 alaReuna.Restitution = 1.0; 64 alaReuna.IsVisible = false; 65 49 66 Level.Background.Color = Color.Black; 50 67 … … 81 98 Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 82 99 100 Keyboard.Listen(Key.Space, ButtonState.Pressed, Begin, "Uusi peli"); 83 101 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 84 102 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); … … 125 143 return laskuri; 126 144 } 145 146 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 147 { 148 if (kohde == oikeaReuna) 149 { 150 pelaajan1Pisteet.Value += 1; 151 } 152 else if (kohde == vasenReuna) 153 { 154 pelaajan2Pisteet.Value += 1; 155 } 127 156 } 157 }
Note: See TracChangeset
for help on using the changeset viewer.