- Timestamp:
- 2012-07-24 11:24:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/AnttiS/pong/pong/pong/pong.cs
r3706 r3708 16 16 PhysicsObject maila1; 17 17 PhysicsObject maila2; 18 19 IntMeter pelaajan1Pisteet; 20 IntMeter pelaajan2Pisteet; 21 22 PhysicsObject vasenreuna; 23 PhysicsObject oikeareuna; 18 24 19 25 … … 24 30 AsetaOhjaimet(); 25 31 Aloitapeli(); 32 LisaaLaskurit(); 33 26 34 } 27 35 void Luokentta() … … 37 45 maila2 = Luomaila(Level.Right - 20.0, 0.0); 38 46 39 Level.CreateBorders(1.0, false); 47 vasenreuna = Level.CreateLeftBorder(); 48 vasenreuna.Restitution = 1.0; 49 vasenreuna.KineticFriction = 0.0; 50 vasenreuna.IsVisible = false; 51 52 oikeareuna = Level.CreateRightBorder(); 53 oikeareuna.Restitution = 1.0; 54 oikeareuna.KineticFriction = 0.0; 55 oikeareuna.IsVisible = false; 56 57 PhysicsObject ylaReuna = Level.CreateTopBorder(); 58 ylaReuna.Restitution = 1.0; 59 ylaReuna.KineticFriction = 0.0; 60 ylaReuna.IsVisible = false; 61 62 PhysicsObject alaReuna = Level.CreateBottomBorder(); 63 alaReuna.Restitution = 1.0; 64 alaReuna.IsVisible = false; 65 alaReuna.KineticFriction = 0.0; 66 67 68 40 69 Level.BackgroundColor = Color.Blue; 70 71 AddCollisionHandler (pallo, KasittelePallonTormays); 41 72 } 42 73 void Aloitapeli() … … 90 121 maila.Velocity = nopeus; 91 122 } 123 void LisaaLaskurit() 124 { 125 pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 126 pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 127 } 128 IntMeter LuoPisteLaskuri(double x, double y) 129 { 130 IntMeter laskuri = new IntMeter ( 0 ); 131 laskuri.MaxValue = 10; 132 133 Label naytto = new Label(); 134 naytto.BindTo(laskuri); 135 naytto.X = x; 136 naytto.Y = y; 137 naytto.TextColor = Color.Yellow ; 138 naytto.BorderColor = Level.BackgroundColor; 139 naytto.Color = Level.BackgroundColor; 140 Add(naytto); 141 142 return laskuri; 143 } 144 void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 145 { 146 if (kohde == oikeareuna) 147 { 148 pelaajan1Pisteet.Value += 1; 149 } 150 else if (kohde == vasenreuna) 151 { 152 pelaajan2Pisteet.Value += 1; 153 } 154 155 } 92 156 93 157 }
Note: See TracChangeset
for help on using the changeset viewer.