- Timestamp:
- 2013-06-13 15:04:44 (10 years ago)
- Location:
- 2013/24/EemeliP/Tasohyppelypeli3/Tasohyppelypeli3
- Files:
-
- 13 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/24/EemeliP/Tasohyppelypeli3/Tasohyppelypeli3/Tasohyppelypeli3/Braaains!!.cs
r4104 r4124 9 9 public class Tasohyppelypeli3 : PhysicsGame 10 10 { 11 int kenttaNro = 1; 12 11 13 const double nopeus = 450; 12 14 const double hyppyNopeus = 800; 13 15 const int RUUDUN_KOKO = 40; 14 16 17 Vector aloituspaikka = Vector.Zero; 15 18 PlatformCharacter pelaaja1; 16 19 20 Image maaliKuva = LoadImage("finish"); 21 Image vaaraKuva = LoadImage("spike"); 17 22 Image pelaajanKuva = LoadImage("ukko"); 18 Image tahtiKuva = LoadImage(" Brains");23 Image tahtiKuva = LoadImage("tahti"); 19 24 20 25 SoundEffect maaliAani = LoadSoundEffect("beep"); … … 24 29 { 25 30 fetusAnimaatio = LoadAnimation("fetus"); 26 27 MultiSelectWindow alkuValikko = new MultiSelectWindow("Braaains!!", 28 "Start", "Close"); 29 //alkuValikko.AddItemHandler(0, AloitaPeli); 31 MultiSelectWindow alkuValikko = new MultiSelectWindow("Braaains!!", "Start", "Close"); 32 alkuValikko.AddItemHandler(0, AloitaPeli); 30 33 alkuValikko.AddItemHandler(1, Exit); 31 34 Add(alkuValikko); 35 32 36 IsFullScreen = true; 33 Gravity = new Vector(0, -1000);34 37 35 LuoKentta(); 36 LisaaNappaimet(); 38 } 37 39 38 Camera.Follow(pelaaja1);39 Camera.ZoomFactor = 1.2;40 Camera.StayInLevel = true;40 void AloitaPeli() 41 { 42 SeuraavaKentta(); 41 43 } 42 44 … … 45 47 MediaPlayer.Play("hotdamned"); 46 48 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 47 kentta.SetTileMethod('#', LisaaTaso);48 kentta.SetTileMethod('*', LisaaTahti);49 kentta.SetTileMethod('N', LisaaPelaaja);50 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO);51 Level.CreateBorders();52 Level.Background.CreateGradient(Color.Red, Color.Black);53 49 } 54 50 … … 71 67 } 72 68 69 void LisaaVaara(Vector paikka, double leveys, double korkeus) 70 { 71 PhysicsObject vaara = PhysicsObject.CreateStaticObject(leveys, korkeus); 72 vaara.IgnoresCollisionResponse = true; 73 vaara.Position = paikka; 74 vaara.Image = vaaraKuva; 75 vaara.Tag = "spike"; 76 Add(vaara); 77 } 78 73 79 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 74 80 { … … 79 85 pelaaja1.Mass = 4.0; 80 86 //pelaaja1.Image = pelaajanKuva; 87 aloituspaikka = paikka; 81 88 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 89 AddCollisionHandler(pelaaja1, "spike", TormaaVaaraan); 90 AddCollisionHandler(pelaaja1, "maali", TormasiMaaliin); 82 91 Add(pelaaja1); 83 92 } 93 94 84 95 85 96 void LisaaNappaimet() … … 118 129 tahti.Destroy(); 119 130 } 120 } 131 132 void TormaaVaaraan(PhysicsObject hahmo, PhysicsObject vaara) 133 { 134 MessageDisplay.Add("Start again"); 135 hahmo.Position = aloituspaikka; 136 } 137 138 void AloitaAlusta() 139 { 140 LuoKentta(); 141 Gravity = new Vector(0, -1000); 142 } 143 144 void LuoKentta(string kenttaNimi) 145 { 146 MediaPlayer.Play(kenttaNimi + "_musiikki"); 147 TileMap kentta = TileMap.FromLevelAsset(kenttaNimi); 148 kentta.SetTileMethod('#', LisaaTaso); 149 kentta.SetTileMethod('M', LisaaMaali); 150 kentta.SetTileMethod('V', LisaaVaara); 151 kentta.SetTileMethod('*', LisaaTahti); 152 kentta.SetTileMethod('N', LisaaPelaaja); 153 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 154 Level.CreateBorders(); 155 Level.Background.CreateGradient(Color.Red, Color.Black); 156 157 } 158 void TormasiMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 159 { 160 kenttaNro++; 161 SeuraavaKentta(); 162 } 163 164 165 void SeuraavaKentta() 166 { 167 ClearAll(); 168 169 if (kenttaNro == 1) LuoKentta("kentta1"); 170 else if (kenttaNro == 2) LuoKentta("kentta2"); 171 else if (kenttaNro == 3) LuoKentta("kentta3"); 172 else if (kenttaNro == 4) LuoKentta("kentta4"); 173 else if (kenttaNro == 5) LuoKentta("kentta5"); 174 else if (kenttaNro > 6) Exit(); 175 176 Gravity = new Vector(0, -1000); 177 LisaaNappaimet(); 178 179 Camera.Follow(pelaaja1); 180 Camera.ZoomFactor = 1.2; 181 Camera.StayInLevel = true; 182 183 } 184 185 void LisaaMaali(Vector paikka, double leveys, double korkeus) 186 { 187 PhysicsObject maali = PhysicsObject.CreateStaticObject(leveys, korkeus); 188 maali.IgnoresCollisionResponse = true; 189 maali.Position = paikka; 190 maali.Image = maaliKuva; 191 maali.Tag = "maali"; 192 Add(maali); 193 } 194 195 } -
2013/24/EemeliP/Tasohyppelypeli3/Tasohyppelypeli3/Tasohyppelypeli3Content/Tasohyppelypeli3Content.contentproj
r4104 r4124 56 56 <Processor>SoundEffectProcessor</Processor> 57 57 </Compile> 58 <Compile Include="norsu.png">59 <Name>norsu</Name>60 <Importer>TextureImporter</Importer>61 <Processor>TextureProcessor</Processor>62 </Compile>63 58 <Compile Include="tahti.png"> 64 59 <Name>tahti</Name> … … 104 99 <Processor>TextureProcessor</Processor> 105 100 </Compile> 106 <Compile Include="stick.png">107 <Name>stick</Name>108 <Importer>TextureImporter</Importer>109 <Processor>TextureProcessor</Processor>110 </Compile>111 101 </ItemGroup> 112 102 <ItemGroup> … … 118 108 </ItemGroup> 119 109 <ItemGroup> 120 <Compile Include=" paikallaan.anim">121 <Name> paikallaan</Name>122 <Importer> AnimationImporter</Importer>123 <Processor> AnimationContentProcessor</Processor>110 <Compile Include="kentta1_musiikki.mp3"> 111 <Name>kentta1_musiikki</Name> 112 <Importer>Mp3Importer</Importer> 113 <Processor>SongProcessor</Processor> 124 114 </Compile> 125 115 </ItemGroup> 126 116 <ItemGroup> 127 <Compile Include="hotdamned.mp3"> 128 <Name>hotdamned</Name> 117 <Compile Include="spike.png"> 118 <Name>spike</Name> 119 <Importer>TextureImporter</Importer> 120 <Processor>TextureProcessor</Processor> 121 </Compile> 122 </ItemGroup> 123 <ItemGroup> 124 <Compile Include="finish.png"> 125 <Name>finish</Name> 126 <Importer>TextureImporter</Importer> 127 <Processor>TextureProcessor</Processor> 128 </Compile> 129 </ItemGroup> 130 <ItemGroup> 131 <Compile Include="kentta2.txt"> 132 <Name>kentta2</Name> 133 <Importer>TextFileImporter</Importer> 134 <Processor>TextFileContentProcessor</Processor> 135 </Compile> 136 </ItemGroup> 137 <ItemGroup> 138 <Compile Include="kentta3.txt"> 139 <Name>kentta3</Name> 140 <Importer>TextFileImporter</Importer> 141 <Processor>TextFileContentProcessor</Processor> 142 </Compile> 143 <Compile Include="kentta4.txt"> 144 <Name>kentta4</Name> 145 <Importer>TextFileImporter</Importer> 146 <Processor>TextFileContentProcessor</Processor> 147 </Compile> 148 <Compile Include="kentta5.txt"> 149 <Name>kentta5</Name> 150 <Importer>TextFileImporter</Importer> 151 <Processor>TextFileContentProcessor</Processor> 152 </Compile> 153 </ItemGroup> 154 <ItemGroup> 155 <Compile Include="braaains.png"> 156 <Name>braaains</Name> 157 <Importer>TextureImporter</Importer> 158 <Processor>TextureProcessor</Processor> 159 </Compile> 160 </ItemGroup> 161 <ItemGroup> 162 <Compile Include="kentta2_musiikki.mp3"> 163 <Name>kentta2_musiikki</Name> 164 <Importer>Mp3Importer</Importer> 165 <Processor>SongProcessor</Processor> 166 </Compile> 167 </ItemGroup> 168 <ItemGroup> 169 <Compile Include="kentta3_musiikki.mp3"> 170 <Name>kentta3_musiikki</Name> 171 <Importer>Mp3Importer</Importer> 172 <Processor>SongProcessor</Processor> 173 </Compile> 174 </ItemGroup> 175 <ItemGroup> 176 <Compile Include="kentta4_musiikki.mp3"> 177 <Name>kentta4_musiikki</Name> 178 <Importer>Mp3Importer</Importer> 179 <Processor>SongProcessor</Processor> 180 </Compile> 181 </ItemGroup> 182 <ItemGroup> 183 <Compile Include="kentta5_musiikki.mp3"> 184 <Name>kentta5_musiikki</Name> 129 185 <Importer>Mp3Importer</Importer> 130 186 <Processor>SongProcessor</Processor> -
2013/24/EemeliP/Tasohyppelypeli3/Tasohyppelypeli3/Tasohyppelypeli3Content/kentta1.txt
r4104 r4124 8 8 ### ### * ### # 9 9 # * ### # # # 10 *# ### # #################################### ############# ############ #############11 ### # * # # # ##10 V # ### # #################################### ############# ############ ############# 11 ### # V * # # # # VVVVVVVVVV VVVVVVVVVV # 12 12 # ### #### * # #* # # # 13 13 * * ############# # # # # # # 14 14 ### ### # # # # # # # 15 N # * # # # # # # ***********************************16 ############################################################################# # # # # # ** ####### ##############################################17 # # # # # # ####18 # # # # # # ### # # # # ## #19 # # * # # # # # # # # # # # #20 # # * ################# ############ ############################ # # # # # # # #21 # # ### # # # # # # # # #22 # # * # # # # # ##15 N VVVVVVVVVVV# * VVVVVVVVVVVVVVVVVVVVVVV# # # # # # M 16 ############################################################################# # # # # # ** ####### 17 # # # # # # V ####VVVVVVV 18 # # # # # # ### 19 # # * # #VVVVVVVVVV# #VVVVVVV V 20 # # * ################# ############ ########################################### 21 # # ### # 22 # # * # 23 23 # # ### # 24 24 # ############### ### #
Note: See TracChangeset
for help on using the changeset viewer.