Changeset 229 for werner_v/Pong-1/Peli.cs
- Timestamp:
- 2009-08-04 10:07:45 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
werner_v/Pong-1/Peli.cs
r218 r229 17 17 #endregion 18 18 19 namespace Pong 119 namespace Pong 20 20 { 21 21 public class Peli : PhysicsGame … … 24 24 PhysicsObject maila1; 25 25 PhysicsObject maila2; 26 Vector2D nopeusYlos = new Vector2D(0, 200); 27 Vector2D nopeusAlas = new Vector2D(0, -200); 26 Vector2D nopeusYlos = new Vector2D(0, 400); 27 Vector2D nopeusAlas = new Vector2D(0, -400); 28 29 Meter<int> Pelaajan1Pisteet; 30 Meter<int> Pelaajan2Pisteet; 31 32 void LisaaLaskurit() 33 { 34 Pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 35 Pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 36 } 37 38 Meter<int> LuoPisteLaskuri(double x, double y) 39 { 40 Meter<int> laskuri = new Meter<int>(0, 0, 10); 41 ValueDisplay naytto = new ValueDisplay(this); 42 naytto.BindTo(laskuri); 43 naytto.X = x; 44 naytto.Y = y; 45 naytto.ValueColor = Color.White; 46 Add(naytto); 47 return laskuri; 48 } 28 49 29 50 protected override void LoadContent() … … 31 52 Level = LuoKentta(); 32 53 AsetaOhjaimet(); 54 LisaaLaskurit(); 33 55 AloitaPeli(); 56 } 57 void KasittelePallonTormays(Collision collision) 58 { 59 PhysicsObject pallo = collision.Obj; 60 PhysicsObject kohde = collision.Other; 61 62 if (kohde == Level.RightBorder) 63 { 64 Pelaajan1Pisteet.Value += 1; 65 } 66 else if (kohde == Level.LeftBorder) 67 { 68 Pelaajan2Pisteet.Value += 1; 69 } 34 70 } 35 71 Level LuoKentta() … … 44 80 pallo.Restitution = 1.0; 45 81 kentta.Objects.Add(pallo); 82 AddCollisionHandler(pallo, KasittelePallonTormays); 46 83 47 84 maila1 = LuoMaila(kentta.Left + 20.0, 0.0, kentta); … … 53 90 void AloitaPeli() 54 91 { 55 Vector2D impulssi = new Vector2D( 2000.0, 0.0);92 Vector2D impulssi = new Vector2D(5000.0, 0.0); 56 93 pallo.Hit(impulssi); 57 94 }
Note: See TracChangeset
for help on using the changeset viewer.