- Timestamp:
- 2010-07-29 11:31:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/30/alkivima/Car Duels/Peli.cs
r1371 r1396 15 15 IntMeter pelaajan1Pisteet; 16 16 IntMeter pelaajan2Pisteet; 17 Label aikaNaytto; 17 18 18 19 protected override void Begin() … … 24 25 auto1.Mass = 100.0; 25 26 auto1.Color = new Color(1, 1, 1); 26 auto1.X = - 200;27 auto1.X = -300; 27 28 auto1.Y = 0; 28 auto1.LinearDamping = 0.9 5;29 auto1.LinearDamping = 0.97; 29 30 auto1.AngularDamping = 0.1; 30 31 auto1.CanRotate = false; 31 32 auto1.Acceleration = 1500; 32 Add(auto1 );33 Add(auto1, 1); 33 34 34 35 auto2 = new Automobile(60, 50); 35 36 auto2.Mass = 100.0; 36 37 auto2.Color = new Color(255, 255, 255); 37 auto2.X = 200;38 auto2.X = 300; 38 39 auto2.Y = 0; 39 auto2.LinearDamping = 0.9 5;40 auto2.LinearDamping = 0.97; 40 41 auto2.AngularDamping = 0.1; 41 42 auto2.Angle = Angle.Degrees(180.0); 42 43 auto2.CanRotate = false; 43 44 auto2.Acceleration = 1500; 44 Add(auto2); 45 45 Add(auto2, 1); 46 47 AssaultRifle pyssy1 = new AssaultRifle(20, 5); 48 pyssy1.Tag = "ase"; 49 auto1.Add(pyssy1); 50 51 AssaultRifle pyssy2 = new AssaultRifle(20, 5); 52 pyssy2.Tag = "ase"; 53 auto2.Add(pyssy2); 54 55 AddCollisionHandler(auto1, KasitteleAuto1Tormays); 56 AddCollisionHandler(auto2, KasitteleAuto2Tormays); 57 58 ShowControlHelp(); 59 60 AsetaOhjaimet(); 61 62 Kentta(); 63 64 Pelaaja1HP(); 65 Pelaaja2HP(); 66 67 LisaaLaskurit(); 68 } 69 void AsetaOhjaimet() 70 { 46 71 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 47 72 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 50 75 Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto1, 2.0); 51 76 Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto1, -2.0); 77 //Keyboard.Listen(Key.V, ButtonState.Down, AmmuAseella1, "Ammu", auto1); 52 78 53 79 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); … … 57 83 Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, 2.0); 58 84 Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto2, -2.0); 59 60 AddCollisionHandler(auto1, KasitteleAuto1Tormays); 61 AddCollisionHandler(auto2, KasitteleAuto2Tormays); 62 63 ShowControlHelp(); 64 65 Kentta(); 66 67 Pelaaja1HP(); 68 Pelaaja2HP(); 69 70 LisaaLaskurit(); 71 } 85 //Keyboard.Listen(Key.RightControl, ButtonState.Down, AmmuAseella2, "Ammu", auto2); 86 } 87 72 88 void kiihdyta(Automobile auto) 73 89 { … … 82 98 void kaanny(Automobile auto, double kaannos) 83 99 { 84 auto.Angle = Angle.Degrees(auto.Angle.Degree + kaannos );100 auto.Angle = Angle.Degrees(auto.Angle.Degree + kaannos * 2); 85 101 } 86 102 87 103 void Kentta() 88 104 { 105 GameObject maata = new GameObject(800.0, 700.0); 106 maata.Shape = Shapes.Circle; 107 maata.Color = Color.Gray; 108 Add(maata); 109 89 110 PhysicsObject pylvas1 = PhysicsObject.CreateStaticObject(50.0, 50.0); 90 111 pylvas1.Shape = Shapes.Rectangle; … … 123 144 Add(pylvas4); 124 145 125 GameObject maata = new GameObject(800.0, 700.0); 126 maata.Shape = Shapes.Circle; 127 maata.Color = Color.Gray; 128 Add(maata); 146 PhysicsObject pylvas5 = PhysicsObject.CreateStaticObject(50.0, 50.0); 147 pylvas5.Shape = Shapes.Rectangle; 148 pylvas5.X = -75; 149 pylvas5.Y = 0; 150 pylvas5.Restitution = 0.2; 151 pylvas5.Tag = "pylvas"; 152 pylvas5.Color = Color.DarkGray; 153 Add(pylvas5); 154 155 PhysicsObject pylvas6 = PhysicsObject.CreateStaticObject(50.0, 50.0); 156 pylvas6.Shape = Shapes.Rectangle; 157 pylvas6.X = 75; 158 pylvas6.Y = 0; 159 pylvas6.Restitution = 0.2; 160 pylvas6.Tag = "pylvas"; 161 pylvas6.Color = Color.DarkGray; 162 Add(pylvas6); 129 163 130 164 GameObject Reuna = new GameObject(70.0, 70.0); … … 160 194 void Pelaaja1Tuhoutuu() 161 195 { 162 int pMaxMaara = 2 10;196 int pMaxMaara = 200; 163 197 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); 164 198 ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); … … 168 202 double x = auto1.X; 169 203 double y = auto1.Y; 170 int pMaara = 200;171 int pMaara2 = 10 ;204 int pMaara = 100; 205 int pMaara2 = 100; 172 206 rajahdys.AddEffect(x, y, pMaara); 173 207 rajahdys2.AddEffect(x, y, pMaara2); … … 179 213 void Pelaaja2Tuhoutuu() 180 214 { 181 int pMaxMaara = 2 10;215 int pMaxMaara = 200; 182 216 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); 183 217 ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); … … 187 221 double x = auto2.X; 188 222 double y = auto2.Y; 189 int pMaara = 200;190 int pMaara2 = 10 ;223 int pMaara = 100; 224 int pMaara2 = 100; 191 225 rajahdys.AddEffect(x, y, pMaara); 192 226 rajahdys2.AddEffect(x, y, pMaara2); … … 242 276 { 243 277 Pelaaja2Tuhoutuu(); 278 } 279 if (auto1.Velocity.Magnitude > auto2.Velocity.Magnitude) 280 { 281 voimaMittari2.Value++; 282 voimaMittari2.Value -= 1; 283 voimaMittari2.Value = voimaMittari2.Value - 1; 244 284 } 245 285 } … … 263 303 void UusiEra() 264 304 { 265 auto1.Destroy();266 auto2.Destroy(); 305 ClearControls(); 306 267 307 voimaMittari.Value = 10; 268 308 voimaMittari2.Value = 10; 269 309 270 Add(auto1); 271 Add(auto2); 272 } 310 auto1.X = -300; 311 auto1.Y = 0; 312 auto2.X = 300; 313 auto2.Y = 0; 314 315 auto1.Angle = new Angle(); 316 auto2.Angle = Angle.Degrees(180.0); 317 318 auto1.Stop(); 319 auto2.Stop(); 320 321 EranAlku(); 322 323 } 324 void AmmuAseella1() 325 { 326 //PhysicsObject ammus = pyssy1.Shoot; 327 //if (ammus != null) 328 { 329 // ammus.Size *= 3; 330 } 331 } 332 void AmmuAseella2() 333 { 334 //PhysicsObject ammus = auto2.Weapon.Shoot; 335 //if (ammus != null) 336 { 337 // ammus.Size *= 3; 338 } 339 } 340 void EranAlku() 341 { 342 Timer aikaLaskuri = new Timer(); 343 aikaLaskuri.Interval = 3; 344 aikaLaskuri.Trigger += AikaLoppui; 345 Add(aikaLaskuri); 346 aikaLaskuri.Start(); 347 348 aikaNaytto = new Label(); 349 aikaNaytto.TextColor = Color.White; 350 aikaNaytto.X = -90.0; 351 aikaNaytto.Y = 0.0; 352 aikaNaytto.DecimalPlaces = 1; 353 aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 354 Add(aikaNaytto); 355 273 356 } 357 358 void AikaLoppui( Timer ajastin ) 359 { 360 MessageDisplay.Add( "Start!" ); 361 MessageDisplay.X = 0.0; 362 MessageDisplay.Y = 100.0; 363 ajastin.Reset(); 364 AsetaOhjaimet(); 365 } 366 367 }
Note: See TracChangeset
for help on using the changeset viewer.