Changeset 7479
- Timestamp:
- 2016-06-21 15:54:06 (6 years ago)
- Location:
- 2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1
- Files:
-
- 10 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.cs
r7472 r7479 10 10 { 11 11 const double nopeus = 200; 12 const double hyppyNopeus = 750;12 const double hyppyNopeus = 850; 13 13 const int RUUDUN_KOKO = 40; 14 14 15 15 PlatformCharacter pelaaja1; 16 16 int kolikoidenMaara = 0; 17 string[] kentat = new string[] { "kentta1", "kentta2", "kentta3" }; 18 int kenttaMenossa = 0; 17 19 Image pelaajanKuva = LoadImage("kärpänen"); 18 20 Image tahtiKuva = LoadImage("Piste"); 19 21 Image AmpiaisenKuva = LoadImage("Ampiainen"); 20 22 21 SoundEffect maaliAani = LoadSoundEffect("maali"); 23 SoundEffect maaliAani = LoadSoundEffect("Kolikko"); 24 SoundEffect hyppyAani = LoadSoundEffect("hyppy"); 22 25 Image pilvenreunat = LoadImage("Pilvi"); 23 26 public override void Begin() 27 { 28 LuoAlkuvalikko(); 29 } 30 void LuoAlkuvalikko () 31 { 32 MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 33 "Aloita peli", "Lopeta"); 34 Add(alkuValikko); 35 alkuValikko.AddItemHandler(0, AloitaPeli); 36 alkuValikko.AddItemHandler(1, Exit); 37 alkuValikko.Color = Color.BlueGray; 38 } 39 void AloitaPeli () 24 40 { 25 41 Gravity = new Vector(0, -1000); … … 32 48 Camera.StayInLevel = true; 33 49 } 34 50 void LisaaAse (Vector paikka, double leveys, double korkeus) 51 { 52 PhysicsObject ase = new PhysicsObject(leveys, korkeus); 53 ase.Position = paikka; 54 ase.Tag = "ase"; 55 Add(ase); 56 } 35 57 void LuoKentta() 36 58 { 37 TileMap kentta = TileMap.FromLevelAsset( "kentta1");59 TileMap kentta = TileMap.FromLevelAsset(kentat[kenttaMenossa]); 38 60 kentta.SetTileMethod('#', LisaaTaso); 39 61 kentta.SetTileMethod('*', LisaaTahti); 40 62 kentta.SetTileMethod('A', LisaaAmpiainen); 41 63 kentta.SetTileMethod('N', LisaaPelaaja); 64 kentta.SetTileMethod('-', LisaaAse); 42 65 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 43 66 Level.CreateBorders(); … … 60 83 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 61 84 taso.Position = paikka; 85 taso.Shape = Shape.FromImage(pilvenreunat); 86 taso.Image = pilvenreunat; 62 87 taso.Color = Color.White; 63 taso.Shape = Shape.FromImage(pilvenreunat); 88 89 64 90 Add(taso); 65 91 } … … 72 98 tahti.Image = tahtiKuva; 73 99 tahti.Tag = "Piste"; 100 kolikoidenMaara++; 74 101 Add(tahti); 75 102 } … … 83 110 AddCollisionHandler(pelaaja1, "Piste", TormaaTahteen); 84 111 AddCollisionHandler(pelaaja1, "ampiainen", TörmääAmpiaiseen); 112 AddCollisionHandler(pelaaja1, "ase", OtaAse); 113 85 114 Add(pelaaja1); 115 } 116 void OtaAse (PhysicsObject pelaaja, PhysicsObject ase) 117 { 118 pelaaja1.Weapon = new AssaultRifle(20, 10); 119 ase.Destroy(); 120 pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 121 } 122 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 123 { 124 ammus.Destroy(); 125 if (kohde.Tag.Equals("ampiainen")) kohde.Destroy(); 86 126 } 87 127 void TörmääAmpiaiseen (PhysicsObject pelaaja, PhysicsObject ampiainen) … … 110 150 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 111 151 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 152 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 112 153 113 154 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); … … 118 159 hahmo.Walk(nopeus); 119 160 } 161 void AmmuAseella(PlatformCharacter pelaaja) 162 { 163 PhysicsObject ammus = pelaaja.Weapon.Shoot(); 164 165 if (ammus != null) 166 { 167 //ammus.Size *= 3; 168 //ammus.Image = ... 169 //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 170 } 171 } 120 172 121 173 void Hyppaa(PlatformCharacter hahmo, double nopeus) 122 174 { 123 175 hahmo.Jump(nopeus); 176 hyppyAani.Play(); 124 177 } 125 178 … … 129 182 MessageDisplay.Add("You get the coin!"); 130 183 tahti.Destroy(); 184 kolikoidenMaara--; 185 186 if (kolikoidenMaara <= 00) SiirrySeuraavaanKenttaan(); 131 187 } 188 void SiirrySeuraavaanKenttaan () 189 { 190 ClearAll(); 191 kenttaMenossa++; 192 if (kenttaMenossa >= kentat.Length) LuoAlkuvalikko(); 193 AloitaPeli(); 194 } 195 132 196 } -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r7472 r7479 7 7 Content\Ampiainen.xnb 8 8 Content\Piste.xnb 9 Content\Kolikko.xnb 10 Content\pilviKuva.xnb 11 Content\kentta2.xnb 12 Content\hyppy.xnb 13 Content\kentta3.xnb -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml
r7472 r7479 36 36 <Options>None</Options> 37 37 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb</Output> 38 <Time>2016-06-2 0T15:55:06.9197804+03:00</Time>38 <Time>2016-06-21T14:13:34.4026624+03:00</Time> 39 39 </Item> 40 40 <Item> … … 45 45 <Options>None</Options> 46 46 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Pilvi.xnb</Output> 47 <Time>2016-06-2 0T13:46:04.9005144+03:00</Time>47 <Time>2016-06-21T11:07:45.0580115+03:00</Time> 48 48 </Item> 49 49 <Item> … … 73 73 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Piste.xnb</Output> 74 74 <Time>2016-06-20T14:38:39.3925679+03:00</Time> 75 </Item> 76 <Item> 77 <Source>Kolikko.wav</Source> 78 <Name>Kolikko</Name> 79 <Importer>WavImporter</Importer> 80 <Processor>SoundEffectProcessor</Processor> 81 <Options>None</Options> 82 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Kolikko.xnb</Output> 83 <Time>2016-06-21T10:54:37.8584315+03:00</Time> 84 </Item> 85 <Item> 86 <Source>pilviKuva.png</Source> 87 <Name>pilviKuva</Name> 88 <Importer>TextureImporter</Importer> 89 <Processor>TextureProcessor</Processor> 90 <Options>None</Options> 91 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pilviKuva.xnb</Output> 92 <Time>2016-06-21T11:01:34.3620072+03:00</Time> 93 </Item> 94 <Item> 95 <Source>kentta2.txt</Source> 96 <Name>kentta2</Name> 97 <Importer>TextFileImporter</Importer> 98 <Processor>TextFileContentProcessor</Processor> 99 <Options>None</Options> 100 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta2.xnb</Output> 101 <Time>2016-06-21T15:38:14.2282009+03:00</Time> 102 </Item> 103 <Item> 104 <Source>hyppy.wav</Source> 105 <Name>hyppy</Name> 106 <Importer>WavImporter</Importer> 107 <Processor>SoundEffectProcessor</Processor> 108 <Options>None</Options> 109 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\hyppy.xnb</Output> 110 <Time>2016-06-21T13:31:55.1291205+03:00</Time> 111 </Item> 112 <Item> 113 <Source>kentta3.txt</Source> 114 <Name>kentta3</Name> 115 <Importer>TextFileImporter</Importer> 116 <Processor>TextFileContentProcessor</Processor> 117 <Options>None</Options> 118 <Output>C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta3.xnb</Output> 119 <Time>2016-06-21T15:47:19.5383937+03:00</Time> 75 120 </Item> 76 121 <BuildSuccessful>true</BuildSuccessful> -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/Tasohyppelypeli1.csproj.FileListAbsolute.txt
r7472 r7479 15 15 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Ampiainen.xnb 16 16 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Piste.xnb 17 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Kolikko.xnb 18 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pilviKuva.xnb 19 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta2.xnb 20 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\hyppy.xnb 21 C:\Users\ohjelmointi\Documents\SaanaR\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta3.xnb -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt
r7472 r7479 7 7 Content\Ampiainen.xnb 8 8 Content\Piste.xnb 9 Content\Kolikko.xnb 10 Content\pilviKuva.xnb 11 Content\kentta2.xnb 12 Content\hyppy.xnb 13 Content\kentta3.xnb -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r7472 r7479 95 95 </Compile> 96 96 </ItemGroup> 97 <ItemGroup> 98 <Compile Include="Kolikko.wav"> 99 <Name>Kolikko</Name> 100 <Importer>WavImporter</Importer> 101 <Processor>SoundEffectProcessor</Processor> 102 </Compile> 103 </ItemGroup> 104 <ItemGroup> 105 <Compile Include="pilviKuva.png"> 106 <Name>pilviKuva</Name> 107 <Importer>TextureImporter</Importer> 108 <Processor>TextureProcessor</Processor> 109 </Compile> 110 </ItemGroup> 111 <ItemGroup> 112 <Compile Include="kentta2.txt"> 113 <Name>kentta2</Name> 114 <Importer>TextFileImporter</Importer> 115 <Processor>TextFileContentProcessor</Processor> 116 </Compile> 117 </ItemGroup> 118 <ItemGroup> 119 <Compile Include="hyppy.wav"> 120 <Name>hyppy</Name> 121 <Importer>WavImporter</Importer> 122 <Processor>SoundEffectProcessor</Processor> 123 </Compile> 124 </ItemGroup> 125 <ItemGroup> 126 <Compile Include="kentta3.txt"> 127 <Name>kentta3</Name> 128 <Importer>TextFileImporter</Importer> 129 <Processor>TextFileContentProcessor</Processor> 130 </Compile> 131 </ItemGroup> 97 132 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 98 133 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2016/25/SaanaR/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/kentta1.txt
r7472 r7479 1 1 2 2 3 3 4 * 4 # * * A*5 # * * ** A** 5 6 ##### #### ##### 6 7 7 * * * *A8 # # # # #8 * * * A 9 # # # # # # # 9 10 10 * * * A*11 * * * * A * 11 12 # # # # # 12 13 … … 14 15 ## ## ## ## # 15 16 16 * 17 * * * * *A * 17 18 ### ### ### ### ### 18 19 19 NA20 * * *N* * * A 20 21 ###########################
Note: See TracChangeset
for help on using the changeset viewer.