Changeset 4236
- Timestamp:
- 2013-06-26 14:52:28 (10 years ago)
- Location:
- 2013/26/MikkoTi
- Files:
-
- 82 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/26/MikkoTi/Pong/Pong/Pong/Pong.cs
r4195 r4236 9 9 public class Pong : PhysicsGame 10 10 { 11 Vector nopeusYlös = new Vector(0, 200);12 Vector nopeusAlas = new Vector(0, - 200);11 Vector nopeusYlös = new Vector(0, 500); 12 Vector nopeusAlas = new Vector(0, -500); 13 13 14 14 PhysicsObject Pallo; 15 15 PhysicsObject Maila1; 16 16 PhysicsObject Maila2; 17 18 PhysicsObject vasenReuna; 19 PhysicsObject oikeaReuna; 17 20 18 21 IntMeter pelaajan1Pisteet; … … 27 30 LisaaLaskurit(); 28 31 AloitaPeli(); 29 32 30 33 } 31 34 … … 37 40 Pallo.X = 200.0; 38 41 Pallo.Y = 0.0; 39 Pallo.Restitution = 1.0; 42 Pallo.MomentOfInertia = Double.PositiveInfinity; 43 Pallo.Restitution = 3.0; 44 AddCollisionHandler(Pallo, KasittelePallonTormays); 40 45 41 46 Maila1 = LuoMaila(Level.Left + 20.0, 0.0); 42 47 Maila2 = LuoMaila(Level.Right - 20.0, 0.0); 43 48 44 Level.CreateBorders(1.0, false); 49 vasenReuna = Level.CreateLeftBorder(); 50 vasenReuna.Restitution = 1.0; 51 vasenReuna.KineticFriction = 0.0; 52 vasenReuna.IsVisible = false; 53 54 oikeaReuna = Level.CreateRightBorder(); 55 oikeaReuna.Restitution = 1.0; 56 oikeaReuna.KineticFriction = 0.0; 57 oikeaReuna.IsVisible = false; 58 59 PhysicsObject ylaReuna = Level.CreateTopBorder(); 60 ylaReuna.Restitution = 1.0; 61 ylaReuna.KineticFriction = 0.0; 62 ylaReuna.IsVisible = false; 63 64 PhysicsObject alaReuna = Level.CreateBottomBorder(); 65 alaReuna.Restitution = 1.0; 66 alaReuna.KineticFriction = 0.0; 67 alaReuna.IsVisible = false; 68 45 69 Level.BackgroundColor = Color.Black; 46 70 … … 70 94 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 71 95 } 96 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 97 { 98 if (kohde == oikeaReuna) 99 { 100 pelaajan1Pisteet.Value += 1; 101 } 102 else if (kohde == vasenReuna) 103 { 104 pelaajan2Pisteet.Value += 1; 105 } 106 } 107 108 109 72 110 IntMeter LuoPisteLaskuri(double x, double y) 73 111 {
Note: See TracChangeset
for help on using the changeset viewer.