Changeset 77
- Timestamp:
- 2009-07-22 10:22:23 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
aki_p/Pong/Peli.cs
r49 r77 22 22 { 23 23 const double mailanNopeus = 200.0; 24 24 25 PhysicsObject pallo; 25 26 PhysicsObject maila1; 26 27 PhysicsObject maila2; 28 29 Meter<int> pelaajan1Pisteet; 30 Meter<int> pelaajan2Pisteet; 27 31 28 32 protected override void LoadContent() … … 30 34 Level = LuoKentta(); 31 35 AsetaOhjaimet(); 36 LisaaLaskurit(); 32 37 AloitaPeli(); 33 38 } … … 55 60 pallo.Restitution = 1.0; 56 61 kentta.Objects.Add(pallo); 62 63 AddCollisionHandler(pallo, KasittelePallonTormays); 57 64 58 65 maila1 = LuoMaila(kentta.Left + 20.0, 0.0, kentta); … … 97 104 } 98 105 106 void LisaaLaskurit() 107 { 108 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 109 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 110 } 111 112 Meter<int> LuoPisteLaskuri(double x, double y) 113 { 114 Meter<int> laskuri = new Meter<int>(0, 0, 10); 115 ValueDisplay naytto = new ValueDisplay(this); 116 naytto.BindTo(laskuri); 117 naytto.X = x; 118 naytto.Y = y; 119 naytto.ValueColor = Color.White; 120 Add(naytto); 121 return laskuri; 122 } 123 124 void KasittelePallonTormays(Collision collision) 125 { 126 PhysicsObject pallo = collision.Obj; 127 PhysicsObject kohde = collision.Other; 128 129 if (kohde == Level.RightBorder) 130 { 131 pelaajan1Pisteet.Value += 1; 132 } 133 else if (kohde == Level.LeftBorder) 134 { 135 pelaajan2Pisteet.Value += 1; 136 } 137 } 138 99 139 void AloitaPeli() 100 140 { 101 Vector2D impulssi = new Vector2D( 2000.0, 0.0);141 Vector2D impulssi = new Vector2D(6000.0, 0.0); 102 142 pallo.Hit(impulssi); 103 143 }
Note: See TracChangeset
for help on using the changeset viewer.