- Timestamp:
- 2013-07-02 15:04:24 (10 years ago)
- Location:
- 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME
- Files:
-
- 11 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME.cs
r4344 r4374 15 15 PlatformCharacter pelaaja1; 16 16 17 Image pelaajanKuva = LoadImage("norsu"); 18 Image tahtiKuva = LoadImage("tahti"); 17 Image[] seisomisanimaatio = LoadImages("Trollface"); 18 Image[] kävelykuvat = LoadImages("Trollface","Trollface2"); 19 Image[] hyokkausanimaatio = LoadImages("Trollfaceampuu"); 19 20 20 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 Image esKuva = LoadImage("es"); 22 Image ammusKuva = LoadImage("Panos"); 23 Timer lataaEnergiaaAjastin = new Timer(); 24 DoubleMeter energia; 25 DoubleMeter elamat; 26 27 SoundEffect laaserAani = LoadSoundEffect("maali"); 21 28 22 29 public override void Begin() 23 30 { 24 31 Gravity = new Vector(0, -1000); 32 25 33 26 34 LuoKentta(); 27 35 LisaaNappaimet(); 36 37 LisaaEnergiaPalkki(); 38 LisaaElamaPalkki(); 39 40 lataaEnergiaaAjastin.Interval = 0.9; 41 lataaEnergiaaAjastin.Timeout += delegate { energia.Value += 1; }; 42 lataaEnergiaaAjastin.Start(); 28 43 29 44 Camera.Follow(pelaaja1); … … 32 47 } 33 48 49 void LisaaEnergiaPalkki() 50 { 51 energia = new DoubleMeter(100, 0, 100); 52 53 ProgressBar energiaPalkki = new ProgressBar(200, 35); 54 energiaPalkki.Position = new Vector(Screen.Right - 150, Screen.Top - 50); 55 energiaPalkki.Color = Color.Blue; 56 energiaPalkki.BarColor = Color.Violet; 57 energiaPalkki.BindTo(energia); 58 Add(energiaPalkki); 59 60 } 61 void LisaaElamaPalkki() 62 { 63 elamat = new DoubleMeter(10, 0, 10); 64 65 ProgressBar ElamaPalkki = new ProgressBar(200, 35); 66 ElamaPalkki.Position = new Vector(Screen.Right - 150, Screen.Top - 10); 67 ElamaPalkki.Color = Color.Blue; 68 ElamaPalkki.BarColor = Color.Red; 69 ElamaPalkki.BindTo(elamat); 70 Add(ElamaPalkki); 71 } 34 72 void LuoKentta() 35 73 { 74 36 75 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 37 76 kentta.SetTileMethod('#', LisaaTaso); … … 40 79 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 41 80 Level.CreateBorders(); 42 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 81 Level.Background.Image = LoadImage("Tausta2"); 82 Level.Background.FitToLevel(); 43 83 } 44 84 … … 56 96 tahti.IgnoresCollisionResponse = true; 57 97 tahti.Position = paikka; 58 tahti.Image = tahtiKuva;59 tahti.Tag = " tahti";98 tahti.Image = esKuva; 99 tahti.Tag = "es"; 60 100 Add(tahti); 61 101 } … … 66 106 pelaaja1.Position = paikka; 67 107 pelaaja1.Mass = 4.0; 68 pelaaja1.Image = pelaajanKuva; 69 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 108 pelaaja1.AnimWalk = new Animation(kävelykuvat); 109 pelaaja1.AnimIdle = new Animation(seisomisanimaatio); 110 AddCollisionHandler(pelaaja1, "es", TormaaTahteen); 111 112 113 //pelaaja1 on PlatformCharacter-tyyppinen 114 pelaaja1.Weapon = new AssaultRifle(30, 10); 115 116 //Ammusten määrä aluksi: 117 pelaaja1.Weapon.Ammo.Value = 5000; 118 pelaaja1.Weapon.FireRate = 5000; 119 pelaaja1.Weapon.IsVisible = false; 120 //Mitä tapahtuu kun ammus osuu johonkin? 121 pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 122 70 123 Add(pelaaja1); 71 124 } 72 125 126 127 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 128 { 129 ammus.Destroy(); 130 } 131 132 133 void AmmuAseella(PlatformCharacter pelaaja) 134 { 135 if (energia.Value < 1) return; 136 PhysicsObject ammus = pelaaja.Weapon.Shoot(); 137 pelaaja1.PlayAnimation(new Animation(hyokkausanimaatio)); 138 energia.Value--; 139 140 if (ammus != null) 141 { 142 ammus.Width *= 2; 143 ammus.Image = ammusKuva; 144 //ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0) 145 } 146 147 } 148 149 150 73 151 void LisaaNappaimet() 74 152 { 153 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 75 154 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 76 155 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); … … 101 180 void TormaaTahteen(PhysicsObject hahmo, PhysicsObject tahti) 102 181 { 103 maaliAani.Play(); 104 MessageDisplay.Add("Keräsit tähden!"); 182 MessageDisplay.Add("Keräsit es energia juoman!"); 105 183 tahti.Destroy(); 106 184 } 185 186 187 188 189 190 191 107 192 } -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kentta1.txt
r4344 r4374 1 * 2 ## 3 4 * * 5 ## ## 6 7 * * 8 ## ## ## 9 10 * * * * 11 ## ## ## ## 12 13 * * * * 14 ## ## ## ## ## 15 16 N 17 ###################### 1 N ########################################### 2 # # 3 ####### # # 4 # # ### # 5 # # ########################## # 6 # ####### # # 7 #### #* # # 8 # # # # ## # 9 # # ##### # ## # 10 # * # # ####################### 11 # ##### # # 12 ##### ##################### #### 13 * ### #### #* # # # 14 # #### ### ## ## ## # 15 # # ## # 16 # # ######## # 17 ##### ######## # # 18 # ## # 19 # # # 20 ######################################################## -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kill_everypody_GAMEContent.contentproj
r4344 r4374 67 67 </Compile> 68 68 </ItemGroup> 69 <ItemGroup> 70 <Compile Include="Trollface.png"> 71 <Name>Trollface</Name> 72 <Importer>TextureImporter</Importer> 73 <Processor>TextureProcessor</Processor> 74 </Compile> 75 </ItemGroup> 76 <ItemGroup> 77 <Compile Include="Trollface2.png"> 78 <Name>Trollface2</Name> 79 <Importer>TextureImporter</Importer> 80 <Processor>TextureProcessor</Processor> 81 </Compile> 82 </ItemGroup> 83 <ItemGroup> 84 <Compile Include="Trollfaceampuu.png"> 85 <Name>Trollfaceampuu</Name> 86 <Importer>TextureImporter</Importer> 87 <Processor>TextureProcessor</Processor> 88 </Compile> 89 </ItemGroup> 90 <ItemGroup> 91 <Compile Include="es.png"> 92 <Name>es</Name> 93 <Importer>TextureImporter</Importer> 94 <Processor>TextureProcessor</Processor> 95 </Compile> 96 </ItemGroup> 97 <ItemGroup> 98 <Compile Include="Panos.png"> 99 <Name>Panos</Name> 100 <Importer>TextureImporter</Importer> 101 <Processor>TextureProcessor</Processor> 102 </Compile> 103 </ItemGroup> 104 <ItemGroup> 105 <Compile Include="Tausta1.jpg"> 106 <Name>Tausta1</Name> 107 <Importer>TextureImporter</Importer> 108 <Processor>TextureProcessor</Processor> 109 </Compile> 110 </ItemGroup> 111 <ItemGroup> 112 <Compile Include="Tausta2.jpg"> 113 <Name>Tausta2</Name> 114 <Importer>TextureImporter</Importer> 115 <Processor>TextureProcessor</Processor> 116 </Compile> 117 </ItemGroup> 69 118 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 70 119 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.