- Timestamp:
- 2012-07-27 12:36:34 (10 years ago)
- Location:
- 2012/30/JesseN/Oma peli/OmaPeli
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/JesseN/Oma peli/OmaPeli/OmaPeli.sln
r3724 r3816 4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmaPeli", "OmaPeli\OmaPeli\OmaPeli.csproj", "{1D158C1A-70E8-4489-B178-22BCDCA68795}" 5 5 EndProject 6 Project("{ 96E2B04D-8817-42C6-938A-82C39BA4D311}") = "OmaPeliContent", "OmaPeli\OmaPeliContent\OmaPeliContent.contentproj", "{D393B661-C31E-4FDE-9903-AA6974CB938F}"6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmaPeliContent", "OmaPeli\OmaPeliContent\OmaPeliContent.contentproj", "{D393B661-C31E-4FDE-9903-AA6974CB938F}" 7 7 EndProject 8 8 Global -
2012/30/JesseN/Oma peli/OmaPeli/OmaPeli/OmaPeli/Ohjelma.cs
r3751 r3816 6 6 static void Main(string[] args) 7 7 { 8 using ( OmaPeli game = new OmaPeli())8 using (MetalFist game = new MetalFist()) 9 9 { 10 10 #if !DEBUG -
2012/30/JesseN/Oma peli/OmaPeli/OmaPeli/OmaPeli/OmaPeli.cs
r3769 r3816 7 7 using Jypeli.Widgets; 8 8 9 public class OmaPeli: PhysicsGame9 public class MetalFist : PhysicsGame 10 10 { 11 11 PlatformCharacter hahmo; 12 Maavihu frog; 12 13 Image hahmostand = LoadImage("CharStand32"); 13 14 Image[] hahmojuoksu = LoadImages("CharRun1", "CharRun2", "CharRun3"); … … 17 18 Image tahtaa = LoadImage("CharShoot32bit"); 18 19 Image[] flyer = LoadImages("EnemyFlying1", "EnemyFlying2", "EnemyFlying3", "EnemyFlying4"); 20 Image[] frogi = LoadImages("EnemyLand1", "EnemyLand2"); 21 Image[] fullmetalli = LoadImages("FullMetal", "FullMetal", "FullMetal"); 19 22 20 23 Image vesiblock = LoadImage("Water"); … … 36 39 Image taustakuva = LoadImage("CloudBackground"); 37 40 Image hpsalkku = LoadImage("Briefcase"); 41 Image enemygun = LoadImage("EnemyGun"); 42 IntMeter pistelaskuri; 38 43 Animation hahmoosuma; 44 Animation fullimetalli; 39 45 ExplosionSystem rajahdys; 40 46 41 47 DoubleMeter elamaLaskuri; 42 48 IntMeter ammuslaskuri; 49 EasyHighScore topLista; 50 43 51 44 52 public override void Begin() 45 53 { 54 ClearAll(); 55 topLista = new EasyHighScore(); 56 topLista.HighScoreWindow.Closed += delegate { Begin(); }; 57 46 58 MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 47 59 "Aloita peli", "Parhaat pisteet", "Lopeta"); … … 49 61 50 62 alkuValikko.ItemSelected += PainettiinValikonNappia; 51 52 53 54 55 56 57 58 59 60 61 62 63 63 64 PhoneBackButton.Listen(ConfirmExit, "Lopeta Peli"); … … 73 74 break; 74 75 case 1: 76 topLista.Show(); 77 break; 78 case 2: 75 79 Exit(); 76 80 break; 77 78 79 81 } 80 82 } 81 83 84 void Alkuvalikkoon() 85 { 86 Camera.Zoom(1.0); 87 ClearAll(); 88 Begin(); 89 return; 90 } 82 91 void LuoTausta() 83 92 { … … 96 105 LuoElamaLaskuri(); 97 106 Luoammustenmaara(); 107 LuoPisteLaskuri(); 98 108 99 109 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Level1"); … … 117 127 ruudut.SetTileMethod(Color.YellowGreen, LuoBorderwall); 118 128 ruudut.SetTileMethod(Color.SpringGreen, LuoAmmuslaatikko); 119 Camera.Zoom(1.2); 129 ruudut.SetTileMethod(Color.Purple, LuoMaaVihu); 130 Camera.Reset(); 131 Camera.Zoom(1.1); 132 Camera.StayInLevel = true; 120 133 121 134 ruudut.Execute(45, 45); … … 134 147 ammobox.CollisionIgnoreGroup = 0; 135 148 ammobox.Tag = "Ammo"; 136 Add(ammobox , -1);149 Add(ammobox); 137 150 } 138 151 … … 144 157 hpbox.CollisionIgnoreGroup = 0; 145 158 hpbox.Tag = "HP"; 146 Add(hpbox , -1);159 Add(hpbox); 147 160 } 148 161 … … 249 262 hahmo.Weapon.CanHitOwner = false; 250 263 AddCollisionHandler<PlatformCharacter, PhysicsObject>(hahmo, "Ammo", Ammuksia); 251 AddCollisionHandler<PlatformCharacter, PhysicsObject>(hahmo, "HP", Hpta); 264 AddCollisionHandler<PlatformCharacter, PhysicsObject>(hahmo, "HP", Hpta); 265 AddCollisionHandler<PlatformCharacter, PhysicsObject>(hahmo, "Vesi", Vesi2 ); 266 AddCollisionHandler<PlatformCharacter, PhysicsObject>(hahmo, "vihollinen", OsumaPelaajaan); 267 fullimetalli = new Animation(fullmetalli); 268 fullimetalli.FPS = 9; 252 269 253 270 Image[] hahmodmg = LoadImages("CharHit", "CharHit2", "CharHit3"); … … 260 277 } 261 278 279 void OsumaPelaajaan(PlatformCharacter hahmo, PhysicsObject lentava ) 280 { 281 elamaLaskuri.Value -= 1; 282 hahmo.PlayAnimation(hahmoosuma); 283 } 284 285 286 void LuoPisteLaskuri() 287 { 288 pistelaskuri = new IntMeter(0); 289 Label pisteNaytto = new Label(); 290 pisteNaytto.X = Screen.Left + 61; 291 pisteNaytto.Y = Screen.Top - 45; 292 pisteNaytto.TextColor = Color.White; 293 pisteNaytto.Color = Color.Black; 294 pisteNaytto.BindTo(pistelaskuri); 295 pisteNaytto.Size = new Vector(28, 40); 296 pisteNaytto.Title = "Points"; 297 Add(pisteNaytto); 298 } 299 300 301 void Vesi2(PlatformCharacter hahmo, PhysicsObject vesi) 302 { 303 hahmo.Hit(new Vector(0, 120)); 304 } 305 262 306 void Hpta(PlatformCharacter hahmo, PhysicsObject hpbox) 263 307 { … … 286 330 } 287 331 332 333 288 334 void LuoRuoho(Vector paikka, double leveys, double korkeus) 289 335 { … … 313 359 void LuoVesi(Vector paikka, double leveys, double korkeus) 314 360 { 315 GameObject vesi = new GameObject(leveys, korkeus);361 PhysicsObject vesi = PhysicsObject.CreateStaticObject(leveys, korkeus); 316 362 vesi.Position = paikka; 317 363 vesi.Image = vesiblock; 364 vesi.IgnoresCollisionResponse = true; 365 vesi.Tag = "Vesi"; 318 366 Add(vesi, -1); 319 367 } … … 325 373 takakivi.Image = takakiviblock; 326 374 Add(takakivi, -1); 375 } 376 377 void LuoMaaVihu(Vector paikka, double leveys, double korkeus) 378 { 379 Maavihu frog = new Maavihu(50, 50); 380 frog.Position = paikka; 381 frog.Animation = new Animation(frogi); 382 frog.Shape = Shape.Circle; 383 frog.Animation.Start(); 384 LaserGun frogun = new LaserGun(30, 20); 385 frog.CanRotate = false; 386 frogun.Ammo.Value = 10000; 387 frogun.Image = enemygun; 388 frogun.Color = Color.Transparent; 389 frogun.Y = -10; 390 frog.Add(frogun); 391 frog.Tag = "vihollinen"; 392 393 394 395 frogun.Destroyed += delegate { vihollinen2tuhottu(frog); }; 396 /*RandomMoverBrain satunnaisAivot = new RandomMoverBrain(200); 397 satunnaisAivot.ChangeMovementSeconds = 3; 398 frog.Brain = satunnaisAivot; */ 399 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 400 tasoAivot.Speed = 100; 401 frog.Brain = tasoAivot; 402 Timer ajastin2 = new Timer(); 403 ajastin2.Interval = 1.7; 404 ajastin2.Timeout += delegate { VihollinenAmpuu(frog, frogun, ajastin2); }; 405 ajastin2.Start(); 406 Add(frog); 327 407 } 328 408 … … 366 446 int pMaara = 50; 367 447 rajahdys.AddEffect(paikka.Position, pMaara); 368 } 369 448 pistelaskuri.Value += 10; 449 } 450 451 void vihollinen2tuhottu(Maavihu paikka) 452 { 453 int pMaara = 50; 454 rajahdys.AddEffect(paikka.Position, pMaara); 455 pistelaskuri.Value += 20; 456 } 370 457 void AmmusViholliseen(PhysicsObject ammus, Vihuclass lentava) 371 458 { 372 459 lentava.Hitpoints.Value -= 1; 373 //pisteet.value += 1; 460 461 } 462 463 void AmmusViholliseen2(PhysicsObject ammus, Maavihu frog) 464 { 465 frog.Hitpoints2.Value -= 1; 374 466 375 467 } … … 381 473 //hahmo.PlayAnimation(...); 382 474 } 475 383 476 384 477 … … 411 504 } 412 505 506 void Vihollinen2Ampuu(PlatformCharacter frog, LaserGun frogun, Timer ajastin2) 507 { 508 if (frog.IsDestroyed == true) 509 { 510 ajastin2.Stop(); 511 return; 512 } 513 514 Vector suunta = (hahmo.Position - frog.Position); 515 if (suunta.Magnitude < 600) 516 { 517 frogun.Angle = suunta.Angle; 518 PhysicsObject ammus2 = frogun.Shoot(); 519 520 if (ammus2 != null) 521 { 522 ammus2.Shape = Shape.Circle; 523 ammus2.Size = new Vector(10, 10); 524 ammus2.Image = panos2; 525 AddCollisionHandler(ammus2, CollisionHandler.DestroyObject); 526 AddCollisionHandler(ammus2, hahmo, AmmusPelaajaan); 527 528 529 530 } 531 } 532 } 413 533 414 534 … … 421 541 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaHahmoa, "Pelaaja liiku oikealle", 400.0); 422 542 Keyboard.Listen(Key.Space, ButtonState.Pressed, hyppy, "Pelaaja hyppää", 650.0); 423 Keyboard.Listen(Key.A, ButtonState.Pressed, AmmuAseella, "Ammu", hahmo); 543 Keyboard.Listen(Key.S, ButtonState.Pressed, AmmuAseella, "Ammu", hahmo); 544 Keyboard.Listen(Key.T, ButtonState.Pressed, Alkuvalikkoon, "Palaa valikkoon"); 545 Keyboard.Listen(Key.Down, ButtonState.Pressed, fullmetal, "Full metal - muoto"); 546 } 547 548 void fullmetal() 549 { 550 hahmo.PlayAnimation(fullimetalli); 551 hahmo.Hit(new Vector(0, -1000)); 552 424 553 } 425 554 … … 449 578 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 450 579 AddCollisionHandler<PhysicsObject, Vihuclass>(ammus, "vihollinen", AmmusViholliseen); 580 AddCollisionHandler<PhysicsObject, Maavihu>(ammus, "vihollinen2", AmmusViholliseen2); 451 581 452 582 } … … 473 603 int pMaara = 50; 474 604 rajahdys.AddEffect(hahmo.Position, pMaara); 605 hahmo.Destroy(); 606 topLista.EnterAndShow(pistelaskuri.Value); 475 607 } 476 608 … … 478 610 void Luoammustenmaara() 479 611 { 612 480 613 Label ammustenmaara = new Label(); 481 614 ammustenmaara.X = Screen.Left + 100; … … 487 620 Add(ammustenmaara); 488 621 } 622 623 489 624 } -
2012/30/JesseN/Oma peli/OmaPeli/OmaPeli/OmaPeli/OmaPeli.csproj
r3769 r3816 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="Maavihu.cs" /> 113 114 <Compile Include="Ohjelma.cs" /> 114 115 <Compile Include="OmaPeli.cs" /> … … 122 123 <ItemGroup> 123 124 <ProjectReference Include="..\OmaPeliContent\OmaPeliContent.contentproj"> 124 <Name>OmaPeliContent </Name>125 <Name>OmaPeliContent %28Content%29</Name> 125 126 <XnaReferenceType>Content</XnaReferenceType> 127 <Project>{D393B661-C31E-4FDE-9903-AA6974CB938F}</Project> 126 128 </ProjectReference> 127 129 </ItemGroup> -
2012/30/JesseN/Oma peli/OmaPeli/OmaPeli/OmaPeliContent/OmaPeliContent.contentproj
r3769 r3816 73 73 </ItemGroup> 74 74 <ItemGroup> 75 <Folder Include="NewFolder1\" /> 76 <Folder Include="NewFolder2\" /> 75 <Compile Include="EnemyLand2.png"> 76 <Name>EnemyLand2</Name> 77 <Importer>TextureImporter</Importer> 78 <Processor>TextureProcessor</Processor> 79 </Compile> 77 80 </ItemGroup> 78 81 <ItemGroup> … … 310 313 <Compile Include="Briefcase.png"> 311 314 <Name>Briefcase</Name> 315 <Importer>TextureImporter</Importer> 316 <Processor>TextureProcessor</Processor> 317 </Compile> 318 </ItemGroup> 319 <ItemGroup> 320 <Compile Include="EnemyLand1.png"> 321 <Name>EnemyLand1</Name> 322 <Importer>TextureImporter</Importer> 323 <Processor>TextureProcessor</Processor> 324 </Compile> 325 </ItemGroup> 326 <ItemGroup> 327 <Compile Include="EnemyGun.png"> 328 <Name>EnemyGun</Name> 329 <Importer>TextureImporter</Importer> 330 <Processor>TextureProcessor</Processor> 331 </Compile> 332 </ItemGroup> 333 <ItemGroup> 334 <Compile Include="FullMetal.png"> 335 <Name>FullMetal</Name> 312 336 <Importer>TextureImporter</Importer> 313 337 <Processor>TextureProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.