- Timestamp:
- 2012-06-08 13:39:57 (11 years ago)
- Location:
- 2012/23/AtteH
- Files:
-
- 13 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/23/AtteH/Tasohyppelypeli1/Tasohyppelypeli1.sln
r2797 r2887 4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasohyppelypeli1", "Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1.csproj", "{40965FF9-7994-4E89-B290-55502A460430}" 5 5 EndProject 6 Project("{ 96E2B04D-8817-42C6-938A-82C39BA4D311}") = "Tasohyppelypeli1Content", "Tasohyppelypeli1\Tasohyppelypeli1Content\Tasohyppelypeli1Content.contentproj", "{75CC2454-0173-4CB4-9D84-787FF6EBF359}"6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasohyppelypeli1Content", "Tasohyppelypeli1\Tasohyppelypeli1Content\Tasohyppelypeli1Content.contentproj", "{75CC2454-0173-4CB4-9D84-787FF6EBF359}" 7 7 EndProject 8 8 Global -
2012/23/AtteH/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.cs
r2806 r2887 14 14 15 15 PlatformCharacter pelaaja1; 16 Vector pelaaja1paikka; 17 bool onkoPeliFullS = false; 18 string mikaTaso = "Kenttä 1"; 16 19 17 20 Image pelaajanKuva = LoadImage("Hahmo"); 18 Image tahtiKuva = LoadImage("tahti"); 19 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 Image tykkiKuva = LoadImage("Tukki"); 22 Image esteKuva = LoadImage("Este"); 23 Image textuuriKuva = LoadImage("Textuuri"); 24 Image mamaKuva = LoadImage("Mama"); 25 SoundEffect arghAani = LoadSoundEffect("argh"); 20 26 Image paikallaanVasemmalle = LoadImage("HahmoReverse"); 21 27 Image paikalleOikealle = LoadImage("Hahmo"); … … 25 31 public override void Begin() 26 32 { 27 Gravity = new Vector(0, -1750); 28 29 luoKentta(); 30 lisaaNappaimet(); 31 32 Camera.Follow(pelaaja1); 33 Camera.ZoomFactor = 1.5; 34 Camera.StayInLevel = true; 33 Gravity = new Vector(0, -1850); 34 SetWindowSize(1024, 768, false); 35 36 37 38 MultiSelectWindow valikko = new MultiSelectWindow("Tervetuloa peliin", 39 "Kenttä 1","Kenttä 2", "Lopeta"); 40 valikko.ItemSelected += PainettiinValikonNappia; 41 Add(valikko); 42 valikko.DefaultCancel = 3; 43 valikko.Color = Color.DarkRed; 44 45 MediaPlayer.Play("8bit Dungeon Level"); 46 47 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 48 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 49 50 51 } 52 53 void Fullscreen() 54 { 55 if (onkoPeliFullS) // jos on koko ruutu 56 { 57 SetWindowSize(1024, 768, false); onkoPeliFullS = false; 58 return; 59 } 60 61 62 //SetWindowSize((int)Screen.Width, (int)Screen.Height, true); onkoPeliFullS = true; 63 int w = Microsoft.Xna.Framework.Graphics.GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; 64 int h = Microsoft.Xna.Framework.Graphics.GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; 65 SetWindowSize(w, h, true); onkoPeliFullS = true; 66 MessageDisplay.Add(Screen.Width + ", " + Screen.Height); 35 67 } 36 68 37 69 void luoKentta() 38 70 { 39 TileMap kentta = TileMap.From File("kentta1.txt");71 TileMap kentta = TileMap.FromLevelAsset(mikaTaso); 40 72 kentta.SetTileMethod('#', lisaaTaso); 41 kentta.SetTileMethod('*', lisaaTahti);42 73 kentta.SetTileMethod('N', lisaaPelaaja); 43 74 kentta.SetTileMethod('E', lisaaPiikki); 75 kentta.SetTileMethod('R', lisaaEste); 76 kentta.SetTileMethod('D', lisaaApu); 77 kentta.SetTileMethod('S', lisaaMama); 44 78 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 45 79 Level.CreateBorders(); 46 Level.Background.CreateGradient(Color.White, Color. SkyBlue);80 Level.Background.CreateGradient(Color.White, Color.Green); 47 81 } 48 82 … … 51 85 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 52 86 taso.Position = paikka; 53 taso. Color = Color.Gray;87 taso.Image = textuuriKuva; 54 88 Add(taso); 55 89 } 56 90 57 void lisaaTahti(Vector paikka, double leveys, double korkeus) 58 { 59 PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 60 tahti.IgnoresCollisionResponse = true; 61 tahti.Position = paikka; 62 tahti.Image = tahtiKuva; 63 tahti.Tag = "tahti"; 64 Add(tahti); 91 void lisaaEste(Vector paikka, double leveys, double korkeus) 92 { 93 PhysicsObject este = PhysicsObject.CreateStaticObject(korkeus, leveys); 94 este.Position = paikka; 95 este.Tag = "Vaara"; 96 este.Image = esteKuva; 97 este.Shape = Shape.Triangle; 98 Add(este); 99 } 100 void PainettiinValikonNappia(int valinta) 101 { 102 switch (valinta) 103 { 104 case 0: 105 mikaTaso = "Kenttä 1"; 106 luoKentta(); 107 lisaaNappaimet(); 108 Camera.Follow(pelaaja1); 109 Camera.ZoomFactor = 1.5; 110 Camera.StayInLevel = true; 111 break; 112 case 1: 113 mikaTaso = "Kenttä 2"; 114 luoKentta(); 115 lisaaNappaimet(); 116 Camera.Follow(pelaaja1); 117 Camera.ZoomFactor = 1.5; 118 Camera.StayInLevel = true; 119 break; 120 case 2: 121 Exit(); 122 break; 123 } 65 124 } 66 125 … … 69 128 pelaaja1 = new PlatformCharacter(leveys, korkeus); 70 129 pelaaja1.Position = paikka; 130 pelaaja1paikka = paikka; 71 131 pelaaja1.Mass = 4.0; 72 132 pelaaja1.Image = pelaajanKuva; 73 133 AddCollisionHandler(pelaaja1, kasittelePelaajanTormays); 74 134 Add(pelaaja1); 135 pelaaja1.Tag = "Tyyppi"; 136 137 75 138 } 76 139 void lisaaPiikki(Vector paikka, double leveys, double korkeus) … … 80 143 piikki.Shape = Shape.Triangle; 81 144 piikki.Color = Color.LightGray; 82 piikki.Tag = " Piikki";145 piikki.Tag = "Vaara"; 83 146 Add(piikki); 84 147 } 148 void lisaaMama(Vector paikka, double leveys, double korkeus) 149 { 150 PhysicsObject mama = PhysicsObject.CreateStaticObject(leveys, korkeus); 151 mama.Image = mamaKuva; 152 mama.Position = paikka; 153 Add(mama); 154 mama.Tag = "Voitto"; 155 } 156 void lisaaApu(Vector paikka, double leveys, double korkeus) 157 { 158 PhysicsObject apu = new PhysicsObject(50, 50); 159 apu.Shape = Shape.Pentagon; 160 apu.Color = Color.DarkBrown; 161 Add(apu); 162 apu.Position = paikka; 163 164 } 85 165 86 166 … … 89 169 { 90 170 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 91 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 92 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 171 Keyboard.Listen(Key.F11, ButtonState.Pressed, Fullscreen, null);//Säätää fullscreeniin 93 172 94 173 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 120 199 } 121 200 201 122 202 void kasittelePelaajanTormays(PhysicsObject hahmo, PhysicsObject kohde) 123 203 { 124 if (kohde.Tag.ToString() == " Piikki")125 { 126 maaliAani.Play();204 if (kohde.Tag.ToString() == "Vaara") 205 { 206 arghAani.Play(); 127 207 Label umad = new Label(); 208 209 umad.TextColor = Color.Crimson; 210 umad.Font = Font.DefaultLarge; 211 umad.Text = "Kuolit!"; 212 umad.MaximumLifetime = new TimeSpan(0, 0, 1); 213 hahmo.Position = pelaaja1paikka; 214 128 215 umad.TextColor = Color.Pink; 129 216 umad.Text = "Hävisit <3"; 130 217 hahmo.Destroy(); 218 131 219 Add(umad); 132 } 133 134 220 221 } 222 if (kohde.Tag.ToString() == "Voitto") 223 { 224 Timer.SingleShot(2.0, Pox); 225 Widget Win = new Widget(LoadImage("Voittokuva")); 226 Add(Win); 227 ClearControls(); 228 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 229 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 230 } 231 232 } 233 void Pox() 234 { 235 Explosion pox = new Explosion(500); 236 Add(pox); 237 pox.Position = pelaaja1.Position; 238 pelaaja1.Destroy(); 135 239 136 240 } -
2012/23/AtteH/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj
r2806 r2887 124 124 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 125 125 </Content> 126 <Compile Include="kentta2.txt" /> 126 127 </ItemGroup> 127 128 <ItemGroup> -
2012/23/AtteH/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/kentta1.txt
r2797 r2887 1 . 2 . 3 #################### . 4 # # . 5 # # . 6 # # # . 7 # # # . 8 # * # # . 9 # #### # # . 10 # # # #EE ### . 11 # N # # # #### ## . 12 #### # # *## . 13 # # ###### ### . 14 #EEEEEEE# # ### . 15 ######### #EE#EE### . 16 #########EEEEEEEEEE . 1 . 2 . 3 #################### . 4 # # ## . 5 # # # . 6 # # ### # . 7 # # # ## # . 8 # # # # # . 9 # #### # # # # . 10 # # # #EE ### ## # . 11 # N # # # #### ## # # # . 12 #### # # ## # R # . 13 # # ###### ### ## ###### . 14 #EEEEEEE# # ### # R # # . 15 ########### ####EE### #### # # # #### # . 16 # #########EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE# #EEEEEEEEEEEEE# # # 17 # #### ################################# ############### # # 18 # ###### RRR # # 19 # ######## R R # # 20 # ########## # # R # # . 21 # ############ ##### # R # # . 22 # ############## # # # 23 # ################ ## ####### D ## EE # 24 # ################## # # # # #R R# # ## #########EE# 25 # RR RRR RRR RRR# #R R# # # #### 26 # # #R R#EEEEEEEEEEEEEEEEEEEEE# 27 # # # #R R####################### 28 # # # #R R# 29 # # # # R# 30 # S # # # R# 31 ##################################R#R#R#R######## -
2012/23/AtteH/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r2797 r2887 75 75 </Compile> 76 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="Este.png"> 79 <Name>Este</Name> 80 <Importer>TextureImporter</Importer> 81 <Processor>TextureProcessor</Processor> 82 </Compile> 83 </ItemGroup> 84 <ItemGroup> 85 <Compile Include="Tukki.png"> 86 <Name>Tukki</Name> 87 <Importer>TextureImporter</Importer> 88 <Processor>TextureProcessor</Processor> 89 </Compile> 90 </ItemGroup> 91 <ItemGroup> 92 <Compile Include="8bit Dungeon Level.mp3"> 93 <Name>8bit Dungeon Level</Name> 94 <Importer>Mp3Importer</Importer> 95 <Processor>SongProcessor</Processor> 96 </Compile> 97 </ItemGroup> 98 <ItemGroup> 99 <Compile Include="Textuuri.png"> 100 <Name>Textuuri</Name> 101 <Importer>TextureImporter</Importer> 102 <Processor>TextureProcessor</Processor> 103 </Compile> 104 </ItemGroup> 105 <ItemGroup> 106 <Compile Include="Mama.png"> 107 <Name>Mama</Name> 108 <Importer>TextureImporter</Importer> 109 <Processor>TextureProcessor</Processor> 110 </Compile> 111 </ItemGroup> 112 <ItemGroup> 113 <Compile Include="Voittokuva.png"> 114 <Name>Voittokuva</Name> 115 <Importer>TextureImporter</Importer> 116 <Processor>TextureProcessor</Processor> 117 </Compile> 118 </ItemGroup> 119 <ItemGroup> 120 <Compile Include="argh.wav"> 121 <Name>argh</Name> 122 <Importer>WavImporter</Importer> 123 <Processor>SoundEffectProcessor</Processor> 124 </Compile> 125 </ItemGroup> 126 <ItemGroup> 127 <Compile Include="Kenttä 2.txt"> 128 <Name>Kenttä 2</Name> 129 <Importer>TextFileImporter</Importer> 130 <Processor>TextFileContentProcessor</Processor> 131 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 132 </Compile> 133 </ItemGroup> 134 <ItemGroup> 135 <Compile Include="Kenttä 1.txt"> 136 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 137 <Name>Kenttä 1</Name> 138 <Importer>TextFileImporter</Importer> 139 <Processor>TextFileContentProcessor</Processor> 140 </Compile> 141 </ItemGroup> 77 142 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 78 143 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.