Changeset 3024
- Timestamp:
- 2012-06-14 15:00:02 (11 years ago)
- Location:
- 2012/24/TatuS/Tasohyppelypeli1
- Files:
-
- 15 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Stickman Fight.cs
r3015 r3024 18 18 Image tahtiKuva = LoadImage("tahti"); 19 19 Image kuva = LoadImage("pelaaja1"); 20 Image Maalinkuva = LoadImage("Goal"); 20 21 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 22 22 23 PlatformCharacter pelaaja2; 23 24 Image pojankuva = LoadImage("poika"); 24 List<Label> valikonKohdat; 25 26 int kenttanro = 1; 25 26 int kenttaNro = 1; 27 DoubleMeter voimaMittari; 28 29 27 30 public override void Begin() 28 31 { 29 seuraavaKentta(kenttanro); 30 Valikko(); 31 32 33 Gravity = new Vector(0, -1000); 34 32 35 33 luoKentta(); 36 34 lisaaNappaimet(); 37 38 35 valikko(); 36 37 38 Gravity = new Vector(0, -1000); 39 39 Camera.Follow(pelaaja1); 40 40 Camera.ZoomFactor = 2; … … 42 42 Camera.StayInLevel = true; 43 43 44 45 46 } 47 void seuraavaKentta() 44 lisaaMittari(); 45 46 47 48 } 49 50 void valikko() 51 { 52 MultiSelectWindow valikko = new MultiSelectWindow("Tervetuloa peliin", 53 "Aloita peli","Huipputulokset" , "Lopeta"); 54 valikko.ItemSelected += PainettiinValikonNappia; 55 Level.BackgroundColor = Color.Blue; 56 Add(valikko); 57 } 58 59 60 61 62 63 void PainettiinValikonNappia(int valinta) 64 { 65 Level.BackgroundColor = Color.Brown; 66 switch (valinta) 67 { 68 case 0: 69 70 break; 71 72 case 1: 73 74 break; 75 76 case 2: 77 Exit(); 78 break; 79 80 81 } 82 } 83 84 85 void SeuraavaKentta(int kentanNro) 48 86 { 49 87 ClearAll(); 50 vasenreuna = Level.CreateLeftBorder(); 51 Level.CreateRightBorder(); 52 alaReuna = Level.CreateBottomBorder(); 53 Level.CreateTopBorder(); 54 55 maali = new PhysicsObject(40, 20); 56 maali.Shape = Shape.Rectangle; 57 maali.mass(10.0); 58 AddCollisionHandler(maali, maaliTormasi); 59 Add(maali); 60 61 if (kentanNro == 1) LuoKentta("kentta1"); 62 else if (kentanNro == 2) LuoKentta("kentta2"); 63 else if (kentanNro > 2) Exit(); 64 65 66 } 67 68 void Valikko() 69 { 70 ClearAll(); 71 72 Level.BackgroundColor = Color.Blue; 73 74 valikonKohdat = new List<Label>(); 75 76 Label kohta1 = new Label("Aloita Uusi Peli"); 77 kohta1.Position = new Vector(0, 40); 78 valikonKohdat.Add(kohta1); 79 80 Label kohta2 = new Label("Lopeta Peli"); 81 kohta2.Position = new Vector(0, -40); 82 valikonKohdat.Add(kohta2); 83 84 foreach (Label valikonKohta in valikonKohdat) 85 { 86 Add(valikonKohta); 87 } 88 89 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 90 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 91 92 Mouse.IsCursorVisible = true; 93 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 94 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 95 96 97 } 98 99 void ValikossaLiikkuminen(AnalogState hiirenTila) 100 { 101 foreach (Label kohta in valikonKohdat) 102 { 103 if (Mouse.IsCursorOn(kohta)) 104 { 105 kohta.TextColor = Color.Red; 106 } 107 else 108 { 109 kohta.TextColor = Color.Black; 110 } 111 112 } 113 } 114 115 void AloitaPeli() 116 { 117 ClearAll(); 118 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa Valikkoon"); 119 } 120 121 122 123 124 125 126 127 88 Gravity = new Vector(0, -1000); 89 if (kentanNro == 1) luoKentta(); 90 else if (kentanNro == 2) LuoKentta2(); 91 else if (kentanNro == 3) LuoKentta3(); 92 } 93 94 95 96 97 void LuoKentta2() 98 { 99 TileMap kentta = TileMap.FromLevelAsset("kentta2"); 100 kentta.SetTileMethod('#', lisaaTaso); 101 kentta.SetTileMethod('*', lisaaMaali); 102 kentta.SetTileMethod('N', lisaaPelaaja); 103 kentta.SetTileMethod('P', lisaapelaaja2); 104 Level.CreateBorders(); 105 Level.BackgroundColor = Color.Brown; 106 } 107 108 void LuoKentta3() 109 { 110 TileMap kentta = TileMap.FromLevelAsset("kentta3"); 111 kentta.SetTileMethod('#', lisaaTaso); 112 kentta.SetTileMethod('*', lisaaMaali); 113 kentta.SetTileMethod('N', lisaaPelaaja); 114 kentta.SetTileMethod('P', lisaapelaaja2); 115 Level.CreateBorders(); 116 Level.BackgroundColor = Color.Brown; 117 } 118 119 120 121 122 123 128 124 void luoKentta() 129 125 { 130 126 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 131 127 kentta.SetTileMethod('#', lisaaTaso); 132 kentta.SetTileMethod('*', lisaa Tahti);128 kentta.SetTileMethod('*', lisaaMaali); 133 129 kentta.SetTileMethod('N', lisaaPelaaja); 134 130 kentta.SetTileMethod('P', lisaapelaaja2); … … 136 132 Level.CreateBorders(); 137 133 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 138 TileMap ruudut = TileMap.FromFile(kentta2); 139 } 140 141 134 135 } 136 137 138 142 139 143 140 void lisaaTaso(Vector paikka, double leveys, double korkeus) … … 145 142 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 146 143 taso.Position = paikka; 147 taso.Color = Color. Green;144 taso.Color = Color.DarkCyan; 148 145 Add(taso); 149 146 } 150 147 151 void lisaa Tahti(Vector paikka, double leveys, double korkeus)148 void lisaaMaali(Vector paikka, double leveys, double korkeus) 152 149 { 153 150 PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); … … 155 152 tahti.Position = paikka; 156 153 tahti.Image = tahtiKuva; 157 tahti.Tag = "t ahti";154 tahti.Tag = "tähti"; 158 155 Add(tahti); 159 156 } … … 192 189 } 193 190 194 void AmmusOsui(PhysicsObject Ammus, PhysicsObject Kohde)191 void AmmusOsui(PhysicsObject Ammus, PhysicsObject pelaaja2) 195 192 { 196 193 … … 203 200 { 204 201 Camera.Follow(pelaaja1, pelaaja2); 205 Camera.ZoomFactor = 2.0;202 Camera.ZoomFactor = 1.0; 206 203 Camera.StayInLevel = true; 207 204 } … … 210 207 void AmmuAseella() 211 208 { 212 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 213 if (ammus != null) 214 { 215 ammus.Size *= 0.5; 216 } 209 PhysicsObject Ammus = pelaaja1.Weapon.Shoot(); 210 if (Ammus != null) 211 { 212 Ammus.Size *= 0.5; 213 Ammus.MaximumLifetime = TimeSpan.FromSeconds(1.1); 214 AddCollisionHandler(Ammus, "pelaaja2", CollisionHandler.DestroyBoth); 215 216 } 217 218 217 219 } 218 220 void TahtaaYlos() … … 241 243 242 244 243 void KasitteleVihollinenKuoli(PhysicsObject Ammus, PhysicsObject kohde) 244 { 245 if (kohde.Tag.ToString() == "pelaaja2") 246 { 245 void KasitteleVihollinenKuoli(PhysicsObject kohde, PhysicsObject Ammus) 246 { 247 if (Ammus.Tag.ToString() == "pelaaja2") 248 { 249 Ammus.Destroy(); 247 250 kohde.Destroy(); 248 251 } … … 250 253 } 251 254 252 void JokuTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 253 { 254 } 255 PhysicsObject lisaaMaali() 256 { 257 PhysicsObject Maali = PhysicsObject.CreateStaticObject(RUUDUN_KOKO, RUUDUN_KOKO); 258 Maali.Image = Maalinkuva; 259 AddCollisionHandler(Maali, KasitteleMaaliinTulo); 260 return Maali; 261 } 262 263 void KasitteleMaaliinTulo(PhysicsObject Maali, PhysicsObject kohde) 264 { 265 if (kohde == pelaaja1) 266 { 267 kenttaNro++; 268 SeuraavaKentta(kenttaNro); 269 } 270 } 271 272 IntMeter pisteLaskuri; 273 274 void LuoLaskuri() 275 { 276 pisteLaskuri = new IntMeter(0); 277 278 Label pisteNaytto = new Label(); 279 pisteNaytto.X = Screen.Left + 100; 280 pisteNaytto.Y = Screen.Top - 100; 281 pisteNaytto.TextColor = Color.Black; 282 pisteNaytto.Color = Color.White; 283 284 pisteNaytto.BindTo(pisteLaskuri); 285 Add(pisteNaytto); 286 287 Label pisteTeksti = new Label("Pisteitä: "); 288 pisteTeksti.X = Screen.Left + 50; 289 pisteTeksti.Y = Screen.Top - 100; 290 pisteTeksti.TextColor = Color.Black; 291 pisteTeksti.Color = Color.White; 292 Add(pisteTeksti); 293 pisteLaskuri.Value++; 294 pisteLaskuri.Value += 1; 295 pisteLaskuri.Value = pisteLaskuri.Value + 1; 296 297 298 299 } 300 301 302 303 255 304 256 305 … … 262 311 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 263 312 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 313 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 264 314 265 315 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 277 327 278 328 279 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");329 280 330 } 281 331 … … 300 350 } 301 351 302 352 void lisaaMittari() 353 { 354 voimaMittari = new DoubleMeter(10); 355 voimaMittari.MaxValue = 10; 356 ProgressBar voimaPalkki = new ProgressBar(150, 10); 357 voimaPalkki.BindTo(voimaMittari); 358 Add(voimaPalkki); 359 360 voimaPalkki.X = Screen.Right - 150; 361 voimaPalkki.Y = Screen.Top - 20; 362 voimaPalkki.Angle = Angle.RightAngle; 363 voimaPalkki.BarColor = Color.Green; 364 voimaPalkki.BorderColor = Color.White; 365 voimaPalkki.Angle = Angle.FromDegrees(90); 366 367 // Kun voima loppuu, kutsutaan VoimaLoppui-aliohjelmaa 368 voimaMittari.LowerLimit += VoimaLoppui; 369 370 Keyboard.Listen(Key.Space, ButtonState.Pressed, 371 VahennaVoimia, "Vähennä pelaajan voimia"); 372 } 373 void VahennaVoimia() 374 { 375 voimaMittari.Value--; 376 } 377 378 void VoimaLoppui(double mittarinArvo) 379 { 380 MessageDisplay.Add("Voimat loppuivat, voi voi."); 381 } 382 383 384 385 386 387 388 389 303 390 304 391 } -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj
r2961 r3024 118 118 <Content Include="Game.ico" /> 119 119 <Content Include="GameThumbnail.png" /> 120 <Content Include="Goal.png" /> 120 121 <Content Include="kentta1.txt"> 121 122 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 122 123 </Content> 124 <Content Include="kentta2.txt" /> 125 <Content Include="kentta3.txt" /> 126 <Content Include="LippaanKuva.png" /> 127 <Content Include="pelaaja1.png" /> 128 <Content Include="poika.png" /> 129 <Content Include="tahti.png" /> 123 130 </ItemGroup> 124 131 <ItemGroup> … … 155 162 </BootstrapperPackage> 156 163 </ItemGroup> 164 <ItemGroup> 165 <None Include="Tasohyppelypeli1Content.contentproj" /> 166 </ItemGroup> 157 167 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 158 168 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" /> -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r3004 r3024 1 Content\maali.xnb2 1 Content\norsu.xnb 3 2 Content\tahti.xnb 4 3 Content\pelaaja1.xnb 4 Content\poika.xnb 5 5 Content\kentta1.xnb 6 Content\poika.xnb 6 Content\kentta2.xnb 7 Content\Goal.xnb 7 8 Content\kentta1.txt 8 9 kentta1.txt -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/bin/x86/Debug/Content/kentta1.txt
r3004 r3024 1 1 2 2 3 PPPP4 3 5 4 6 7 5 8 6 P 9 7 10 8 11 # ##### 12 ## # ## # 13 ## # PPP ### #### 14 # # PPPPP ##### ## # 15 N ######## ### PP ######PPP 9 P 10 ############################# 11 N # 12 ######## # 13 # ############ 14 # P P P # 15 #################################### # 16 PPPPPPP # 17 ############################################# 18 19 PPPPPPPPPPPPPPPPP 16 20 ######################################################### -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/ContentPipeline-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}.xml
r3004 r3024 2 2 <XnaContent xmlns:Pipeline="Microsoft.Xna.Framework.Content.Pipeline"> 3 3 <Asset Type="Pipeline:BuildItemCollection"> 4 <Item>5 <Source>maali.wav</Source>6 <Name>maali</Name>7 <Importer>WavImporter</Importer>8 <Processor>SoundEffectProcessor</Processor>9 <Options>None</Options>10 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\maali.xnb</Output>11 <Time>2012-06-12T13:30:27.2478195+03:00</Time>12 </Item>13 4 <Item> 14 5 <Source>norsu.png</Source> … … 39 30 </Item> 40 31 <Item> 41 <Source>kentta1.txt</Source>42 <Name>kentta1</Name>43 <Importer>TextFileImporter</Importer>44 <Processor>TextFileContentProcessor</Processor>45 <Options>None</Options>46 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb</Output>47 <Time>2012-06-13T13:50:40.9804236+03:00</Time>48 </Item>49 <Item>50 32 <Source>poika.png</Source> 51 33 <Name>poika</Name> … … 55 37 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb</Output> 56 38 <Time>2012-06-13T12:24:05.6658537+03:00</Time> 39 </Item> 40 <Item> 41 <Source>kentta1.txt</Source> 42 <Name>kentta1</Name> 43 <Importer>TextFileImporter</Importer> 44 <Processor>TextFileContentProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb</Output> 47 <Time>2012-06-14T14:54:35.5555954+03:00</Time> 48 </Item> 49 <Item> 50 <Source>kentta2.txt</Source> 51 <Name>kentta2</Name> 52 <Importer>TextFileImporter</Importer> 53 <Processor>TextFileContentProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta2.xnb</Output> 56 <Time>2012-06-14T10:51:15.7347521+03:00</Time> 57 </Item> 58 <Item> 59 <Source>Goal.png</Source> 60 <Name>Goal</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Goal.xnb</Output> 65 <Time>2012-06-14T13:07:30.0700481+03:00</Time> 57 66 </Item> 58 67 <BuildSuccessful>true</BuildSuccessful> … … 71 80 <Assembly> 72 81 <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 73 <Value>2012-0 4-23T14:23:36+03:00</Value>82 <Value>2012-06-13T10:59:54+03:00</Value> 74 83 </Assembly> 75 84 <Assembly> -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/Tasohyppelypeli1.csproj.FileListAbsolute.txt
r3004 r3024 1 1 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\kentta1.txt 2 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\maali.xnb3 2 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\norsu.xnb 4 3 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\tahti.xnb … … 15 14 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.txt 16 15 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb 16 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta2.xnb 17 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Goal.xnb -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/cachefile-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}-targetpath.txt
r3004 r3024 1 Content\maali.xnb2 1 Content\norsu.xnb 3 2 Content\tahti.xnb 4 3 Content\pelaaja1.xnb 4 Content\poika.xnb 5 5 Content\kentta1.xnb 6 Content\poika.xnb 6 Content\kentta2.xnb 7 Content\Goal.xnb 7 8 Content\kentta1.txt -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r3015 r3024 45 45 </ItemGroup> 46 46 <ItemGroup> 47 <Compile Include="maali.wav">48 <Name>maali</Name>49 <Importer>WavImporter</Importer>50 <Processor>SoundEffectProcessor</Processor>51 </Compile>52 47 <Compile Include="norsu.png"> 53 48 <Name>norsu</Name> … … 90 85 </Compile> 91 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="Goal.png"> 89 <Name>Goal</Name> 90 <Importer>TextureImporter</Importer> 91 <Processor>TextureProcessor</Processor> 92 </Compile> 93 </ItemGroup> 92 94 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 93 95 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/kentta1.txt
r3004 r3024 1 1 2 2 3 PPPP4 3 5 4 6 7 5 8 6 P 9 7 10 8 11 # ##### 12 ## # ## # 13 ## # PPP ### #### 14 # # PPPPP ##### ## # 15 N ######## ### PP ######PPP 9 P 10 ############################# 11 N # 12 ######## # 13 # ############ 14 # P P P # 15 #################################### # 16 PPPPPPP # 17 ############################################# 18 19 PPPPPPPPPPPPPPPPP 16 20 ######################################################### -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/kentta2.txt
r3004 r3024 15 15 ######## ##### ######## #### 16 16 # # # # # # 17 # PPPP ## # # ###17 # PP ## # # #P ## 18 18 ########## ## # ##### 19 19 # # # 20 20 # # 21 # PP#22 # PPP PPPPP#21 # # 22 # PPP P P# 23 23 ########3
Note: See TracChangeset
for help on using the changeset viewer.