Changeset 1349
- Timestamp:
- 2010-07-28 09:57:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/pesosant/Pong/Peli.cs
r1343 r1349 12 12 PhysicsObject maila1; 13 13 PhysicsObject maila2; 14 15 14 15 PhysicsObject vasenReuna; 16 PhysicsObject oikeaReuna; 17 16 18 IntMeter pelaajan1Pisteet; 17 19 IntMeter pelaajan2Pisteet; … … 31 33 void LuoKentta() 32 34 { 33 AddCollisionHandler(pallo, KasittelePallonTormays);34 35 35 pallo = new PhysicsObject(40.0, 40.0); 36 36 pallo.Shape = Shapes.Circle; … … 39 39 pallo.Restitution = 1.0; 40 40 Add(pallo); 41 41 AddCollisionHandler(pallo, KasittelePallonTormays); 42 42 43 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 43 44 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 45 46 vasenReuna = Level.CreateLeftBorder(); 47 vasenReuna = Level.CreateLeftBorder(); 48 vasenReuna.Restitution = 1.0; 49 vasenReuna.IsVisible = false; 50 oikeaReuna = Level.CreateRightBorder(); 51 oikeaReuna.Restitution = 1.0; 52 oikeaReuna.IsVisible = false; 53 PhysicsObject ylaReuna = Level.CreateTopBorder(); 54 ylaReuna.Restitution = 1.0; 55 ylaReuna.IsVisible = false; 56 PhysicsObject alaReuna = Level.CreateBottomBorder(); 57 alaReuna.Restitution = 1.0; 58 alaReuna.IsVisible = false; 44 59 45 46 Level.CreateBorders(1.0, false );47 60 Level.BackgroundColor = Color.Black; 48 61 49 62 Camera.ZoomToLevel(); 63 64 MessageDisplay.TextColor = Color.White; 50 65 51 66 } … … 62 77 63 78 } 79 void LisaaLaskurit() 80 { 81 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 82 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 83 } 84 IntMeter LuoPisteLaskuri(double x, double y) 85 { 86 IntMeter laskuri = new IntMeter(0); 87 laskuri.MaxValue = 10; 88 Label naytto = new Label(); 89 naytto.BindTo(laskuri); 90 naytto.X = x; 91 naytto.Y = y; 92 naytto.TextColor = Color.White; 93 Add(naytto); 94 return laskuri; 95 } 64 96 97 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 98 { 99 if (kohde == oikeaReuna) 100 { 101 pelaajan1Pisteet.Value += 1; 102 } 103 else if (kohde == vasenReuna) 104 { 105 pelaajan2Pisteet.Value += 1; 106 } 107 108 109 } 65 110 66 111 void AloitaPeli() … … 135 180 maila.Velocity = nopeus; 136 181 } 137 138 IntMeter LuoPisteLaskuri(double x, double y)139 {140 IntMeter laskuri = new IntMeter(0);141 laskuri.MaxValue = 10;142 Label naytto = new Label();143 naytto.BindTo(laskuri);144 naytto.X = x;145 naytto.Y = y;146 naytto.TextColor = Color.White;147 Add(naytto);148 return laskuri;149 }150 void LisaaLaskurit()151 {152 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0);153 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0);154 }155 156 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde)157 {158 }159 182 160 183
Note: See TracChangeset
for help on using the changeset viewer.