- Timestamp:
- 2012-07-05 14:22:17 (11 years ago)
- Location:
- 2012/27/LeoL/Marsun matkat/Marsun matkat
- Files:
-
- 9 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkat/Marsun_matkat.cs
r3553 r3589 14 14 15 15 PlatformCharacter pelaaja1; 16 PlatformCharacter pelaaja2; 16 17 17 18 Image pelaajanKuva = LoadImage("norsu"); 19 Image pelaajan2Kuva = LoadImage("joke joke"); 18 20 Image tahtiKuva = LoadImage("tahti"); 19 21 Image vihunKuva = LoadImage("mulkkis"); 20 22 Image psyykkisKuva = LoadImage("psyykkis"); 21 23 Image hyppisKuva = LoadImage("hyppis"); 24 Image lurkkisKuva = LoadImage("lurkkis"); 25 Image taplisKuva = LoadImage("taplis"); 26 Image konnaKuva = LoadImage("konna"); 22 27 23 28 IntMeter vihunHp = new IntMeter(3); … … 29 34 public override void Begin() 30 35 { 31 36 32 37 33 38 LuoKentta(); … … 39 44 string kenttaNimi = "kentta1"; 40 45 if (kentanNro == 2) 41 {42 46 kenttaNimi = "kentta2"; 43 }44 47 if (kentanNro == 3) 45 {46 48 kenttaNimi = "kentta3"; 47 } 49 if (kentanNro == 4) 50 kenttaNimi = "kentta4"; 51 if (kentanNro == 5) 52 kenttaNimi = "kentta5"; 53 if (kentanNro == 6) 54 kenttaNimi = "kentta6"; 48 55 ClearAll(); 49 56 Gravity = new Vector(0, -1000); … … 52 59 kentta.SetTileMethod('*', LisaaTahti); 53 60 kentta.SetTileMethod('N', LisaaPelaaja); 61 kentta.SetTileMethod('n', LisaaPelaaja2); 54 62 kentta.SetTileMethod('V', LisaaVihu1); 55 63 kentta.SetTileMethod('M', LisaaVihu2); 56 64 kentta.SetTileMethod('S', LisaaVihu3); 65 kentta.SetTileMethod('L', LisaaVihu4); 66 kentta.SetTileMethod('O', LisaaVihu5); 67 kentta.SetTileMethod('K', LisaaVihu6); 57 68 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 58 69 Level.CreateBorders(); 59 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 60 70 71 if (kentanNro == 6) 72 { 73 Level.Background.CreateGradient(Color.DarkRed, Color.Black); 74 MediaPlayer.Play("vika"); 75 } 76 else 77 { 78 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 79 MediaPlayer.Play("muut"); 80 } 61 81 LisaaNappaimet(); 62 82 vihunHp.Value = 3; … … 97 117 } 98 118 119 void LisaaVihu4(Vector paikka, double leveys, double korkeus) 120 { 121 PhysicsObject vihu = new PhysicsObject(40, 20); 122 vihu.Shape = Shape.Rectangle; 123 vihu.Mass = 10.5; 124 vihu.Tag = "vihu"; 125 vihu.Image = lurkkisKuva; 126 Add(vihu); 127 } 128 129 void LisaaVihu5(Vector paikka, double leveys, double korkeus) 130 { 131 PhysicsObject vihu = new PhysicsObject(40, 20); 132 vihu.Shape = Shape.Rectangle; 133 vihu.Mass = 10.5; 134 vihu.Tag = "vihu"; 135 vihu.Image = taplisKuva; 136 Add(vihu); 137 } 138 139 void LisaaVihu6(Vector paikka, double leveys, double korkeus) 140 { 141 PhysicsObject vihu = new PhysicsObject(40, 20); 142 vihu.Shape = Shape.Rectangle; 143 vihu.Mass = 10.5; 144 vihu.Tag = "vihu"; 145 vihu.Image = konnaKuva; 146 Add(vihu); 147 } 148 99 149 void LisaaTaso(Vector paikka, double leveys, double korkeus) 100 150 { 101 151 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 102 152 taso.Position = paikka; 103 taso.Color = Color.Green; 153 if (kentanNro == 6) 154 taso.Image = LoadImage("tiili"); 155 else 156 taso.Image = LoadImage("maa"); 157 taso.Tag = "taso"; 104 158 Add(taso); 105 159 } … … 121 175 pelaaja1.Mass = 4.0; 122 176 pelaaja1.Image = pelaajanKuva; 123 AddCollisionHandler(pelaaja1, Tormaa); 177 AddCollisionHandler(pelaaja1, "tahti", TormattiinTahteen); 178 AddCollisionHandler(pelaaja1, "vihu", TormattiinVihuun); 124 179 Add(pelaaja1); 180 } 181 182 void LisaaPelaaja2(Vector paikka, double leveys, double korkeus) 183 { 184 pelaaja2 = new PlatformCharacter(leveys, korkeus); 185 pelaaja2.Position = paikka; 186 pelaaja2.Mass = 4.0; 187 pelaaja2.Image = pelaajan2Kuva; 188 AddCollisionHandler(pelaaja2, "tahti", TormattiinTahteen); 189 AddCollisionHandler(pelaaja2, "vihu", TormattiinVihuun); 190 Add(pelaaja2); 125 191 } 126 192 … … 135 201 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 136 202 203 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 204 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, nopeus); 205 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja2, hyppyNopeus); 206 137 207 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 138 208 … … 154 224 } 155 225 156 void Tormaa(PhysicsObject hahmo, PhysicsObject kohde) 157 { 158 if (kohde.Tag.ToString() == "vihu") 159 { 160 if (hahmo.Bottom >= kohde.Top) 226 void TormattiinVihuun(PhysicsObject hahmo, PhysicsObject kohde) 227 { 228 if (hahmo.Bottom >= kohde.Top) 229 { 230 vihunHp.Value--; 231 bool sijaintiSopiva = false; 232 Vector tulevaSijainti = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 233 while (!sijaintiSopiva) 161 234 { 162 vihunHp.Value--; 163 kohde.Position = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 235 foreach (GameObject go in GetObjectsWithTag("taso")) 236 { 237 if (!go.IsInside(tulevaSijainti)) 238 { 239 sijaintiSopiva = true; 240 } 241 else 242 { 243 sijaintiSopiva = false; 244 tulevaSijainti = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 245 break; 246 } 247 248 } 164 249 } 165 if (vihunHp.Value <= 0) 166 { 167 kohde.Destroy(); 168 kentanNro++; 169 LuoKentta(); 170 } 171 172 } 173 174 if (kohde.Tag.ToString() == "tahti") 175 { 176 maaliAani.Play(); 177 MessageDisplay.Add("Keräsit tähden!"); 250 kohde.Position = tulevaSijainti; 251 } 252 253 if (vihunHp.Value <= 0) 254 { 178 255 kohde.Destroy(); 179 } 180 } 181 256 kentanNro++; 257 LuoKentta(); 258 } 259 } 260 261 void TormattiinTahteen(PhysicsObject hahmo, PhysicsObject kohde) 262 { 263 maaliAani.Play(); 264 MessageDisplay.Add("Keräsit tähden!"); 265 kohde.Destroy(); 266 } 182 267 } -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/Marsun matkatContent.contentproj
r3553 r3589 108 108 </Compile> 109 109 </ItemGroup> 110 <ItemGroup> 111 <Compile Include="lurkkis.png"> 112 <Name>lurkkis</Name> 113 <Importer>TextureImporter</Importer> 114 <Processor>TextureProcessor</Processor> 115 </Compile> 116 </ItemGroup> 117 <ItemGroup> 118 <Compile Include="taplis.png"> 119 <Name>taplis</Name> 120 <Importer>TextureImporter</Importer> 121 <Processor>TextureProcessor</Processor> 122 </Compile> 123 </ItemGroup> 124 <ItemGroup> 125 <Compile Include="kentta5.txt"> 126 <Name>kentta5</Name> 127 <Importer>TextFileImporter</Importer> 128 <Processor>TextFileContentProcessor</Processor> 129 </Compile> 130 </ItemGroup> 131 <ItemGroup> 132 <Compile Include="konna.png"> 133 <Name>konna</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 </ItemGroup> 138 <ItemGroup> 139 <Compile Include="kentta6.txt"> 140 <Name>kentta6</Name> 141 <Importer>TextFileImporter</Importer> 142 <Processor>TextFileContentProcessor</Processor> 143 </Compile> 144 </ItemGroup> 145 <ItemGroup> 146 <Compile Include="vika.mp3"> 147 <Name>vika</Name> 148 <Importer>Mp3Importer</Importer> 149 <Processor>SongProcessor</Processor> 150 </Compile> 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="muut.mp3"> 154 <Name>muut</Name> 155 <Importer>Mp3Importer</Importer> 156 <Processor>SongProcessor</Processor> 157 </Compile> 158 </ItemGroup> 159 <ItemGroup> 160 <Compile Include="joke joke.png"> 161 <Name>joke joke</Name> 162 <Importer>TextureImporter</Importer> 163 <Processor>TextureProcessor</Processor> 164 </Compile> 165 </ItemGroup> 166 <ItemGroup> 167 <Compile Include="maa.png"> 168 <Name>maa</Name> 169 <Importer>TextureImporter</Importer> 170 <Processor>TextureProcessor</Processor> 171 </Compile> 172 </ItemGroup> 173 <ItemGroup> 174 <Compile Include="tiili.png"> 175 <Name>tiili</Name> 176 <Importer>TextureImporter</Importer> 177 <Processor>TextureProcessor</Processor> 178 </Compile> 179 </ItemGroup> 110 180 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 111 181 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta1.txt
r3553 r3589 1 1 2 2 3 3 … … 17 17 ########### 18 18 # 19 19 nN 20 20 ############## ######################## 21 21 ############ ************ -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta2.txt
r3553 r3589 3 3 4 4 5 N5 n N 6 6 ############## 7 7 -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta3.txt
r3553 r3589 1 1 ## 2 2 N ## ## 3 ## ## ## ##3 n ## ## ## ## 4 4 ## ## ## ## ## S 5 5 ## ## ## ## -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta4.txt
r3553 r3589 1 1 2 ######################## 3 L 4 ########### ############## ############ 2 ############################ 3 # # L 4 # # ########### ############## ############ 5 ### ### 6 ########### #### 5 7 6 ########### 7 8 ########################## 8 #### ########################## 9 9 10 10 ####### 11 11 12 13 ######### ##14 12 #### 13 ######### 14 15 15 ############## 16 16 17 17 ############## N 18 18 n 19 19 ################################ ####### ##### ######
Note: See TracChangeset
for help on using the changeset viewer.