- Timestamp:
- 2011-08-05 12:33:10 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/HenryS/TankDuel/TankDuel/TankDuel/Peli.cs
r2566 r2607 9 9 { 10 10 public int Elamat = 3; 11 12 11 public Tankki(double leveys, double korkeus) 13 12 : base(leveys, korkeus) … … 36 35 Cannon tykki; 37 36 Cannon kanuuna; 38 IntMeter pisteLaskuri;39 IntMeter pisteLaskuri2;37 DoubleMeter pisteLaskuri; 38 DoubleMeter pisteLaskuri2; 40 39 LaserGun pelaajan1Laser; 41 40 LaserGun pelaajan2laserase; 41 Label pelaaja1elamanaytto; 42 Label pelaaja2elamanaytto; 42 43 public override void Begin() 43 44 { … … 161 162 int i = 0; 162 163 163 while (i < 30)164 while (i < 20) 164 165 { 165 166 este = PhysicsObject.CreateStaticObject(60.0, 60.0); 166 167 este.Color = Color.Gray; 167 168 este.CanRotate = false; 168 este.X = RandomGen.NextDouble( Level.Left, Level.Right);169 este.Y = RandomGen.NextDouble( Level.Left, Level.Right);169 este.X = RandomGen.NextDouble(-330.0, 330.0); 170 este.Y = RandomGen.NextDouble(-330.0, 330.0); 170 171 Add(este); 171 172 i++; … … 186 187 ClearAll(); 187 188 valikonKohdat = new List<Label>(); 188 189 Level.BackgroundColor = Color.Black; 189 190 Label kohta1 = new Label("Aloita uusi peli"); 190 191 kohta1.Position = new Vector(0, 40); … … 194 195 kohta2.Position = new Vector(0, -40); 195 196 valikonKohdat.Add(kohta2); 196 197 197 198 foreach (Label valikonKohta in valikonKohdat) 198 199 { … … 212 213 213 214 void ValikossaLiikkuminen(AnalogState hiirenTila) 214 { 215 { 216 215 217 foreach (Label kohta in valikonKohdat) 216 218 { 217 219 if (Mouse.IsCursorOn(kohta)) 218 220 { 219 kohta.TextColor = Color. Red;221 kohta.TextColor = Color.Blue; 220 222 } 221 223 else 222 224 { 223 kohta.TextColor = Color. Black;225 kohta.TextColor = Color.Red; 224 226 } 225 227 … … 236 238 luopelaaja2(); 237 239 luopelaaja1(); 240 luoElamat(); 241 luoElamat2(); 238 242 AsetaOhjaimet(); 239 243 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); … … 302 306 laserammus.CanRotate = false; 303 307 laserammus.Size *= 30; 304 308 305 309 306 310 } … … 321 325 void LuoLaskuri() 322 326 { 323 pisteLaskuri = new IntMeter(100);327 pisteLaskuri = new DoubleMeter(100); 324 328 325 329 Label pisteNaytto = new Label(); … … 327 331 pisteNaytto.Y = Screen.Top - 100; 328 332 pisteNaytto.TextColor = Color.Red; 329 333 pisteNaytto.DecimalPlaces = 0; 330 334 pisteNaytto.BindTo(pisteLaskuri); 331 335 Add(pisteNaytto); … … 339 343 340 344 } 341 void laskuriAlarajassa( intarvo)345 void laskuriAlarajassa(Double arvo) 342 346 { 343 347 pelaaja1.Elamat--; 348 pelaaja1elamanaytto.Text = pelaaja1.Elamat.ToString(); 344 349 pelaaja1.Destroy(); 345 350 pisteLaskuri.Value = 100; 346 351 Explosion rajahdys = new Explosion(250); 352 rajahdys.Position = pelaaja1.Position; 353 Add(rajahdys); 354 rajahdys.Speed = 500.0; 355 rajahdys.Force = 5000; 347 356 if (pelaaja1.Elamat == 0) 348 357 { 349 358 350 359 } 351 360 … … 361 370 void LuoLaskuri2() 362 371 { 363 pisteLaskuri2 = new IntMeter(100);372 pisteLaskuri2 = new DoubleMeter(100); 364 373 365 374 Label pisteNaytto = new Label(); … … 367 376 pisteNaytto.Y = Screen.Top - 100; 368 377 pisteNaytto.TextColor = Color.Red; 369 378 pisteNaytto.DecimalPlaces = 0; 370 379 pisteNaytto.BindTo(pisteLaskuri2); 371 380 Add(pisteNaytto); 372 381 Label pisteTeksti = new Label("Health: "); 373 pisteTeksti.X = Screen.Right - 150;382 pisteTeksti.X = Screen.Right - 200; 374 383 pisteTeksti.Y = Screen.Top - 100; 375 384 pisteTeksti.TextColor = Color.Red; … … 381 390 } 382 391 383 void laskuriAlarajassa2( intarvo)392 void laskuriAlarajassa2(Double arvo) 384 393 { 385 394 pelaaja2.Elamat--; 386 pelaaja1.Destroy(); 395 pelaaja2.Destroy(); 396 pelaaja2elamanaytto.Text = pelaaja2.Elamat.ToString(); 387 397 pisteLaskuri2.Value = 100; 398 Explosion rajahdys = new Explosion(250); 399 rajahdys.Position = pelaaja2.Position; 400 Add(rajahdys); 401 rajahdys.Speed = 500.0; 402 rajahdys.Force = 5000; 403 388 404 389 405 if (pelaaja2.Elamat == 0) 390 406 { 391 407 408 392 409 } 393 410 … … 449 466 { 450 467 451 laserammus2.Destroy();468 452 469 453 470 if (kohde2 == pelaaja2) 454 471 { 455 pisteLaskuri2.Value = pisteLaskuri2.Value - 1;456 472 pisteLaskuri2.Value = pisteLaskuri2.Value - 0.1; 473 laserammus2.Destroy(); 457 474 458 475 } … … 463 480 { 464 481 465 laserammus.Destroy();482 466 483 467 484 if (kohde == pelaaja1) 468 485 { 469 pisteLaskuri.Value = pisteLaskuri.Value - 1;470 486 pisteLaskuri.Value = pisteLaskuri.Value - 0.1; 487 laserammus.Destroy(); 471 488 472 489 } … … 481 498 482 499 luopelaaja1(); 483 } 484 500 ClearControls(); 501 AsetaOhjaimet(); 502 503 } 504 485 505 void ajastinLaukesi2() 486 506 { … … 490 510 AsetaOhjaimet(); 491 511 } 512 void luoElamat() 513 514 { 515 //elamaLaskuri = new DoubleMeter(100); 516 517 pelaaja1elamanaytto = new Label(pelaaja1.Elamat.ToString()); 518 pelaaja1elamanaytto.X = Screen.Left + 100; 519 pelaaja1elamanaytto.Y = Screen.Top - 80; 520 //elamaNaytto.TextColor = Color.Red; 521 //elamaNaytto.DecimalPlaces = 0; 522 // elamaNaytto.BindTo(pelaaja1.Elamat); 523 Add(pelaaja1elamanaytto); 524 Label elamateksti = new Label("Lives: "); 525 elamateksti.X = Screen.Left + 50; 526 elamateksti.Y = Screen.Top - 80; 527 elamateksti.TextColor = Color.Red; 528 Add(elamateksti); 529 } 530 531 void luoElamat2() 532 { 533 //elamaLaskuri = new DoubleMeter(100); 534 535 pelaaja2elamanaytto = new Label(pelaaja2.Elamat.ToString()); 536 pelaaja2elamanaytto.X = Screen.Right - 100; 537 pelaaja2elamanaytto.Y = Screen.Top - 80; 538 //elamaNaytto.TextColor = Color.Red; 539 //elamaNaytto.DecimalPlaces = 0; 540 // elamaNaytto.BindTo(pelaaja1.Elamat); 541 Add(pelaaja2elamanaytto); 542 Label elamateksti2 = new Label("Lives: "); 543 elamateksti2.X = Screen.Right - 150; 544 elamateksti2.Y = Screen.Top - 80; 545 elamateksti2.TextColor = Color.Red; 546 Add(elamateksti2); 547 } 492 548 493 549
Note: See TracChangeset
for help on using the changeset viewer.