Changeset 3957
- Timestamp:
- 2013-04-27 16:18:22 (10 years ago)
- Location:
- 2012/kerho/LeoL/Tasohyppelypeli1/Tasohyppelypeli1
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/kerho/LeoL/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.cs
r3946 r3957 14 14 15 15 PlatformCharacter pelaaja1; 16 PlatformCharacter koopa; 16 17 PlatformCharacter goomba; 17 18 Image tausta = LoadImage("Taustat/Tausta"); … … 24 25 Animation mario_kavelee = new Animation(LoadImages("Mario/mario_1", "Mario/mario_2")); 25 26 Animation goomba_kavelee = new Animation(LoadImages("Goomba/goomba1", "Goomba/goomba2")); 26 27 28 SoundEffect maaliAani = LoadSoundEffect("maali"); 27 Animation koopa_kavelee = new Animation(LoadImages("Koopa/koopa", "Koopa/koopa2")); 28 29 30 SoundEffect kuoliAani = LoadSoundEffect("smb_mariodie"); 31 SoundEffect maaliAani = LoadSoundEffect("smb_coin"); 32 33 //Pelin alussa ollaan kentässä 1 34 int kenttaNro = 1; 29 35 30 36 public override void Begin() 31 37 { 32 Gravity = new Vector(0, -1000);33 34 LuoKentta();35 LisaaNappaimet(); 38 39 SeuraavaKentta(); 40 MediaPlayer.Play("musaa"); 41 36 42 37 43 Camera.Follow(pelaaja1); … … 40 46 } 41 47 42 void LuoKentta() 43 { 44 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 48 void LuoKentta(string kentanNimi) 49 { 50 TileMap kentta = TileMap.FromLevelAsset(kentanNimi); 51 kentta.SetTileMethod('K', LisaaVihu2); 52 kentta.SetTileMethod('m', LisaaMaali); 45 53 kentta.SetTileMethod('G', LisaaVihu); 46 54 kentta.SetTileMethod('#', LisaaNurmikko); … … 48 56 kentta.SetTileMethod('*', LisaaTahti); 49 57 kentta.SetTileMethod('M', LisaaPelaaja); 58 kentta.SetTileMethod('r', LisaaRotko); 50 59 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 51 60 Level.CreateBorders(); … … 91 100 pelaaja1.AnimJump = mario_hyppaa; 92 101 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 102 AddCollisionHandler(pelaaja1, "vihu", TormaaVihuun); 103 AddCollisionHandler(pelaaja1, "Rotko", TormaaRotkoon); 104 AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 93 105 Add(pelaaja1); 94 106 } … … 99 111 goomba.Position = paikka; 100 112 goomba.Mass = 4.0; 101 goomba_kavelee.FPS = 5;113 //goomba.Animation.FPS = 5; 102 114 goomba.AnimIdle = vihunkuva; 103 goomba.AnimWalk = goomba_kavelee; 115 goomba.AnimWalk = new Animation(goomba_kavelee); 116 goomba.Tag = "vihu"; 104 117 Add(goomba); 105 118 … … 143 156 tahti.Destroy(); 144 157 } 158 void TormaaVihuun(PhysicsObject hahmo, PhysicsObject vihu) 159 { 160 pelaaja1.Destroy(); 161 kuoliAani.Play(); 162 } 163 void LisaaRotko(Vector paikka, double leveys, double korkeus) 164 { 165 PhysicsObject rotko = new PhysicsObject(leveys, korkeus); 166 rotko.Position = paikka; 167 rotko.IsVisible = false; 168 rotko.Mass = 4.0; 169 rotko.Tag = "Rotko"; 170 Add(rotko); 171 172 } 173 174 void TormaaRotkoon(PhysicsObject hahmo, PhysicsObject rotko) 175 { 176 pelaaja1.Destroy(); 177 kuoliAani.Play(); 178 } 179 180 void TormaaMaaliin(PhysicsObject pelaaja1, PhysicsObject maali) 181 { 182 183 //Kasvatetaan kenttänumeroa yhdellä ja siirrytään seuraavaan kenttään: 184 kenttaNro = kenttaNro + 1; 185 SeuraavaKentta(); 186 } 187 void SeuraavaKentta() 188 { 189 ClearAll(); 190 191 if (kenttaNro == 1) LuoKentta("kentta1"); 192 else if (kenttaNro == 2) LuoKentta("kentta2"); 193 else if (kenttaNro == 3) LuoKentta("kentta3"); 194 else if (kenttaNro > 3) Exit(); 195 196 LisaaNappaimet(); 197 Gravity = new Vector(0, -1000); 198 199 } 200 201 void LisaaMaali(Vector paikka, double leveys, double korkeus) 202 { 203 PhysicsObject maali = new PhysicsObject(leveys, korkeus); 204 //maali.IgnoresCollisionResponse = true; 205 maali.Position = paikka; 206 maali.IsVisible = false; 207 maali.Tag = "maali"; 208 Add(maali); 209 } 210 void LisaaVihu2(Vector paikka, double leveys, double korkeus) 211 { 212 koopa = new PlatformCharacter(leveys, korkeus); 213 koopa.Position = paikka; 214 koopa.Mass = 4.0; 215 //koopa.Animation.FPS = 5; 216 koopa.AnimIdle = vihunkuva; 217 koopa.AnimWalk = new Animation(goomba_kavelee); 218 koopa.Tag = "vihu"; 219 Add(koopa); 220 221 PlatformWandererBrain goombaAivot = new PlatformWandererBrain(); 222 goombaAivot.Speed = 100; 223 goomba.Brain = goombaAivot; 224 } 145 225 } -
2012/kerho/LeoL/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r3946 r3957 3 3 Content\tahti.xnb 4 4 Content\nurmikko.xnb 5 Content\kentta1.xnb6 5 Content\Kolikko.xnb 7 6 Content\Mario\mario_1.xnb … … 11 10 Content\Goomba\goomba1.xnb 12 11 Content\Taustat\Tausta.xnb 12 Content\kentta1.xnb 13 Content\musaa.xnb 14 Content\smb_coin.xnb 15 Content\smb_mariodie.xnb 16 Content\Koopa\koopa.xnb 17 Content\Koopa\koopa2.xnb 18 Content\musaa.wma -
2012/kerho/LeoL/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r3946 r3957 123 123 </Compile> 124 124 </ItemGroup> 125 <ItemGroup> 126 <Compile Include="musaa.mp3"> 127 <Name>musaa</Name> 128 <Importer>Mp3Importer</Importer> 129 <Processor>SongProcessor</Processor> 130 </Compile> 131 </ItemGroup> 132 <ItemGroup> 133 <Compile Include="smb_coin.wav"> 134 <Name>smb_coin</Name> 135 <Importer>WavImporter</Importer> 136 <Processor>SoundEffectProcessor</Processor> 137 </Compile> 138 </ItemGroup> 139 <ItemGroup> 140 <Compile Include="smb_mariodie.wav"> 141 <Name>smb_mariodie</Name> 142 <Importer>WavImporter</Importer> 143 <Processor>SoundEffectProcessor</Processor> 144 </Compile> 145 </ItemGroup> 146 <ItemGroup> 147 <Compile Include="Koopa\koopa.png"> 148 <Name>koopa</Name> 149 <Importer>TextureImporter</Importer> 150 <Processor>TextureProcessor</Processor> 151 </Compile> 152 <Compile Include="Koopa\koopa2.png"> 153 <Name>koopa2</Name> 154 <Importer>TextureImporter</Importer> 155 <Processor>TextureProcessor</Processor> 156 </Compile> 157 </ItemGroup> 125 158 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 126 159 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/kerho/LeoL/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/kentta1.txt
r3946 r3957 5 5 6 6 7 8 9 M * * * G G G10 ####################### ##### ##### ####### G ## ### ### ### ###### 7 8 9 M * * * * G G * * * * * * K K G m 10 ####################### ##### ##### ####### G ## ### ### ### ###### K # 11 11 TTTTTTTTTTTTTTTTTTTTTTT TTTTT TTTTT TTTTTTT####TT TTT TTT TTT TTTTTT ######T 12 TTTTTTTTTTTTTTTTTTTTTTTrrrTTTTTrrTTTTTrrTTTTTTTTTTTTTrrTTTrrTTTrrTTTrrTTTTTTrrTTTTTTT
Note: See TracChangeset
for help on using the changeset viewer.