- Timestamp:
- 2011-06-14 14:58:15 (12 years ago)
- Location:
- 2011/24/PauliN
- Files:
-
- 31 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/PauliN/Peli.cs
r1958 r1991 17 17 PhysicsObject maila2; 18 18 19 PhysicsObject vasenReuna; 20 PhysicsObject oikeaReuna; 21 22 IntMeter Pelaajan1Pisteet; 23 IntMeter Pelaajan2Pisteet; 24 19 25 public override void Begin() 20 26 { 21 27 LuoKentta (); 22 28 AsetaOhjaimet(); 29 LisaaLaskurit(); 23 30 Aloitapeli (); 24 31 } … … 39 46 pallo.Y = 0; 40 47 pallo.Restitution = 1.0; 48 pallo.KineticFriction = 0.0; 49 AddCollisionHandler(pallo, KasittelePallonTormays); 41 50 42 51 maila1 = LuoMaila (Level.Left + 20, 0); … … 45 54 Camera.ZoomToLevel(); 46 55 47 Level.CreateBorders(1.0, false); 56 vasenReuna = Level.CreateLeftBorder(); 57 vasenReuna.Restitution = 1; 58 vasenReuna.IsVisible = false; 59 60 oikeaReuna = Level.CreateRightBorder(); 61 vasenReuna.Restitution = 1; 62 vasenReuna.IsVisible = false; 63 64 PhysicsObject yläReuna = Level.CreateTopBorder(); 65 yläReuna.Restitution = 1; 66 yläReuna.IsVisible = false; 67 68 PhysicsObject alaReuna = Level.CreateBottomBorder(); 69 alaReuna.Restitution = 1; 70 alaReuna.IsVisible = false; 71 72 73 48 74 Level.BackgroundColor = Color.Black; 49 75 MessageDisplay.TextColor = Color.White; 76 77 AddCollisionHandler (pallo, KasittelePallonTormays); 50 78 51 79 … … 89 117 90 118 } 91 void AsetaNopeus(PhysicsObject Maila, Vector Nopeus) 119 120 void AsetaNopeus ( PhysicsObject Maila, Vector Nopeus) 92 121 { 93 if (Maila.Top > Level.Top) 122 if ( (Nopeus.Y < 0 ) && (Maila.Bottom < Level.Bottom) ) 123 { 124 Maila.Velocity = Vector.Zero; 125 return; 126 } 127 128 if ( (Nopeus.Y > 0 ) && (Maila.Top > Level.Top) ) 94 129 { 95 130 Maila.Velocity = Vector.Zero; 96 131 return; 97 132 } 98 133 134 Maila.Velocity = Nopeus; 135 } 136 void LisaaLaskurit() 137 { 138 Pelaajan1Pisteet = LuoPisteLaskuri ( Screen.Left + 100.0 , Screen.Top - 100.0 ); 139 Pelaajan2Pisteet = LuoPisteLaskuri ( Screen.Right - 100.0 , Screen.Top - 100.0 ); 140 } 141 IntMeter LuoPisteLaskuri (double x, double y) 142 { 143 IntMeter laskuri = new IntMeter(0); 144 laskuri.MaxValue = 10; 145 Label naytto = new Label(); 146 naytto.BindTo(laskuri); 147 naytto.X = x; 148 naytto.Y = y; 149 naytto.TextColor = Color.White; 150 naytto.BorderColor = Level.BackgroundColor; 151 naytto.Color = Level.BackgroundColor; 152 Add(naytto); 153 154 return laskuri; 155 } 99 156 100 157 101 158 102 Maila.Velocity = Nopeus; 159 160 void KasittelePallonTormays ( PhysicsObject pallo, PhysicsObject kohde ) 161 { 162 if (kohde == oikeaReuna) 163 { 164 Pelaajan1Pisteet.Value += 1; 165 } 166 else if (kohde == vasenReuna) 167 { 168 Pelaajan2Pisteet.Value += 1; 169 170 } 171 103 172 } 104 173
Note: See TracChangeset
for help on using the changeset viewer.