Changeset 6995 for 2015/30/SamuelL/jotain/jotain
- Timestamp:
- 2015-07-23 15:03:02 (8 years ago)
- Location:
- 2015/30/SamuelL/jotain/jotain
- Files:
-
- 10 added
- 4 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/30/SamuelL/jotain/jotain/jotain/jotain.cs
r6938 r6995 14 14 15 15 PlatformCharacter pelaaja1; 16 AssaultRifle ase1; 17 bool ase1Flipattu = false; 16 18 17 19 Image pelaajanKuva = LoadImage("pelaajakuva"); … … 25 27 Image Pimeyskuva = LoadImage("pimeys"); 26 28 Image valokuva = LoadImage("valokuva"); 27 Image Luola = LoadImage("luola"); 29 Image luolapaikka = LoadImage("luolapaikka"); 30 Image Isokivi = LoadImage("kivi2"); 31 Image pienikivi = LoadImage("kivi"); 32 Image puu = LoadImage("puuu"); 33 Image Asekuva = LoadImage("GUN"); 34 Image Tähtäin = LoadImage("tähtäin"); 35 28 36 int kenttänumero = 1; 29 37 … … 32 40 SoundEffect maaliAani = LoadSoundEffect("maali"); 33 41 SoundEffect TuliPalo = LoadSoundEffect("tuli"); 42 SoundEffect pistolshot = LoadSoundEffect("PistolShot"); 34 43 35 44 public override void Begin() … … 41 50 void LuoKentta() 42 51 { 43 TileMap kentta = TileMap.FromLevelAsset("kentta" +kenttänumero);52 TileMap kentta = TileMap.FromLevelAsset("kentta" + kenttänumero); 44 53 kentta.SetTileMethod('#', LisaaTaso); 45 54 kentta.SetTileMethod('*', LisaaTahti); … … 50 59 kentta.SetTileMethod('T', Lisaatuli); 51 60 kentta.SetTileMethod('V', LisaaVaihto); 61 kentta.SetTileMethod('O', Lisaakivi, Isokivi, 1); 62 kentta.SetTileMethod('o', Lisaakivi, pienikivi, -1); 63 kentta.SetTileMethod('p', Lisaapuu, puu, 1); 52 64 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 53 65 kentta.Optimize('#'); 54 Level.CreateBorders();55 66 if (kenttänumero == 1) 56 67 { … … 59 70 else if (kenttänumero == 2) 60 71 { 61 Level.Background.Image = Luola;72 Level.Background.Image = luolapaikka; 62 73 } 63 74 Level.Background.FitToLevel(); … … 71 82 taso.Position = paikka; 72 83 taso.IsVisible = true; 84 taso.Tag = "taso"; 73 85 Add(taso); 74 86 taso.Color = Color.Black; 75 87 } 76 void LisaaKasvi(Vector paikka, double leveys, double korkeus, Image kuva,int taso)77 { 78 GameObject kasvi = new GameObject(leveys *1.5,korkeus*3);79 kasvi.Position = paikka + new Vector 80 Add(kasvi, taso);88 void LisaaKasvi(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 89 { 90 GameObject kasvi = new GameObject(leveys * 1.5, korkeus * 3); 91 kasvi.Position = paikka + new Vector(0, 0); 92 Add(kasvi, taso); 81 93 kasvi.Image = kuva; 82 94 … … 88 100 } 89 101 90 void Lisaaruoho(Vector paikka, double leveys, double korkeus, Image kuva,int taso)91 { 92 GameObject ruoho = new GameObject(leveys, korkeus);93 ruoho.Position = paikka + new Vector 94 Add(ruoho, taso);102 void Lisaaruoho(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 103 { 104 GameObject ruoho = new GameObject(leveys, korkeus); 105 ruoho.Position = paikka + new Vector(); 106 Add(ruoho, taso); 95 107 ruoho.Image = kuva; 96 108 … … 109 121 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 110 122 { 111 pelaaja1 = new PlatformCharacter(leveys *1.5, korkeus*1.5);123 pelaaja1 = new PlatformCharacter(leveys * 1.5, korkeus * 1.5); 112 124 pelaaja1.Position = paikka; 113 125 pelaaja1.Mass = 4.0; 114 126 pelaaja1.Image = pelaajanKuva; 127 pelaaja1.Tag = "pelaaja1"; 115 128 pelaaja1.AnimWalk = kävely; 116 129 pelaaja1.AnimIdle = new Animation(pelaajanKuva); … … 121 134 122 135 GameObject pimeys = new GameObject(2700, 2700); 136 pimeys.IsVisible = true; 123 137 pimeys.Image = Pimeyskuva; 124 Add(pimeys, 2);138 Add(pimeys, 2); 125 139 Timer ajastin = new Timer(); 126 140 ajastin.Interval = 0.05; … … 130 144 }; 131 145 ajastin.Start(); 146 147 ase1 = new AssaultRifle(Asekuva.Width, Asekuva.Height); 148 ase1.Image = Asekuva; 149 ase1.Size *= 0.1; 150 ase1.Power.Value = 2000; 151 ase1.FireRate = 2.0; 152 ase1.Tag = "ase"; 153 ase1.AttackSound = pistolshot; 154 155 156 157 158 Add(ase1); 132 159 } 133 160 … … 137 164 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 138 165 139 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 140 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 141 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 166 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 167 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 168 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 169 Mouse.Listen(MouseButton.Left, ButtonState.Down, ammuaseella, "Liikkuu vasemmalle"); 170 142 171 143 172 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 144 173 145 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 146 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 147 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 174 ControllerOne.Listen(Button.A, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 175 ControllerOne.Listen(Button.B, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 176 ControllerOne.Listen(Button.BigButton, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 177 Mouse.IsCursorVisible = false; 178 179 180 181 GameObject hiiri = new GameObject(Tähtäin); 182 hiiri.Size *= 0.1; 183 Add(hiiri, 3); 184 185 Timer hiiriAjastin = new Timer(); 186 hiiriAjastin.Interval = 0.01; 187 hiiriAjastin.Timeout += delegate 188 { 189 hiiri.Position = Mouse.PositionOnWorld; 190 }; 191 hiiriAjastin.Start(); 192 193 Mouse.ListenMovement(0.0, KaannetaanAsetta, ""); 148 194 149 195 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 196 } 197 void KaannetaanAsetta(AnalogState hiirenTila) 198 { 199 Vector suunta = Mouse.PositionOnWorld - pelaaja1.Position; 200 ase1.Position = pelaaja1.Position + suunta.Normalize() * 30; 201 ase1.Angle = suunta.Angle; 202 203 double kulma = suunta.Angle.Degrees; 204 205 if (kulma < 90 && kulma > -90) 206 { 207 if (ase1Flipattu) 208 { 209 ase1.FlipImage(); 210 ase1Flipattu = false; 211 } 212 } 213 else 214 { 215 if (!ase1Flipattu) 216 { 217 ase1.FlipImage(); 218 ase1Flipattu = true; 219 } 220 } 221 150 222 } 151 223 … … 213 285 Camera.ZoomFactor = 1.2; 214 286 Camera.StayInLevel = true; 215 } 216 void tormaavaihtoon(PhysicsObject pelaaja,PhysicsObject vaihto) 287 288 if (kenttänumero == 1) 289 { 290 MediaPlayer.Play("tuli"); 291 MediaPlayer.IsRepeating = true; 292 } 293 else if (kenttänumero == 2) 294 { 295 MediaPlayer.Stop(); 296 } 297 } 298 void tormaavaihtoon(PhysicsObject pelaaja, PhysicsObject vaihto) 217 299 { 218 300 VaihdaKenttaa(); … … 221 303 222 304 } 305 void Lisaakivi(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 306 { 307 GameObject Isokivi = new GameObject(leveys * 1, korkeus * 1); 308 Isokivi.Position = paikka + new Vector(0, 0); 309 Add(Isokivi, taso); 310 Isokivi.Image = kuva; 311 312 } 313 void Lisaapuu(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 314 { 315 GameObject puu = new GameObject(leveys * 3, korkeus * 3); 316 puu.Position = paikka + new Vector(0, 0); 317 Add(puu, taso); 318 puu.Image = kuva; 319 320 321 322 } 323 void ammuaseella() 324 { 325 PhysicsObject ammus = ase1.Shoot(); 326 327 if (ammus != null) 328 { 329 ammus.MaximumLifetime = TimeSpan.FromSeconds(5); 330 331 AddCollisionHandler(ammus, "taso", delegate(PhysicsObject a, PhysicsObject b) 332 { 333 ammus.Destroy(); 334 }); 335 } 336 } 337 223 338 } -
2015/30/SamuelL/jotain/jotain/jotain/jotain.csproj.Debug.cachefile
r6938 r6995 8 8 Content\tausta 1.xnb 9 9 Content\kÀvely loulassa.xnb 10 Content\tuli.xnb11 10 Content\kÀvely ruohossa.xnb 12 Content\kivi 2.xnb13 Content\kivi.xnb14 Content\luola.xnb15 11 Content\spooky.xnb 16 12 Content\tulikuva.xnb … … 32 28 Content\pelaaja\pelaaja9_0.xnb 33 29 Content\pelaajaputoaa.xnb 30 Content\tuli.xnb 31 Content\luolapaikka.xnb 32 Content\kivi2.xnb 33 Content\puu.xnb 34 Content\puuu.xnb 35 Content\GUN.xnb 36 Content\tÀhtÀin.xnb 37 Content\PistolShot.xnb 38 Content\tuli.wma -
2015/30/SamuelL/jotain/jotain/jotainContent/jotainContent.contentproj
r6938 r6995 68 68 </ItemGroup> 69 69 <ItemGroup> 70 <Compile Include="tausta - kasvit 2.png">71 <Name>tausta - kasvit 2</Name>72 <Importer>TextureImporter</Importer>73 <Processor>TextureProcessor</Processor>74 </Compile>75 </ItemGroup>76 <ItemGroup>77 70 <Compile Include="tausta - kasvi 1.png"> 78 71 <Name>tausta - kasvi 1</Name> … … 96 89 </ItemGroup> 97 90 <ItemGroup> 98 <Compile Include="kivi 2.png"> 99 <Name>kivi 2</Name> 100 <Importer>TextureImporter</Importer> 101 <Processor>TextureProcessor</Processor> 102 </Compile> 103 <Compile Include="kivi.png"> 104 <Name>kivi</Name> 105 <Importer>TextureImporter</Importer> 106 <Processor>TextureProcessor</Processor> 107 </Compile> 108 <Compile Include="luola.png"> 109 <Name>luola</Name> 91 <Compile Include="kivi2.png"> 92 <Name>kivi2</Name> 110 93 <Importer>TextureImporter</Importer> 111 94 <Processor>TextureProcessor</Processor> … … 115 98 <Compile Include="kävely loulassa.wav"> 116 99 <Name>kävely loulassa</Name> 117 <Importer>WavImporter</Importer>118 <Processor>SoundEffectProcessor</Processor>119 </Compile>120 <Compile Include="tuli.wav">121 <Name>tuli</Name>122 100 <Importer>WavImporter</Importer> 123 101 <Processor>SoundEffectProcessor</Processor> … … 185 163 <Importer>TextureImporter</Importer> 186 164 <Processor>TextureProcessor</Processor> 165 </Compile> 166 </ItemGroup> 167 <ItemGroup> 168 <Compile Include="tuli.mp3"> 169 <Name>tuli</Name> 170 <Importer>Mp3Importer</Importer> 171 <Processor>SongProcessor</Processor> 172 </Compile> 173 </ItemGroup> 174 <ItemGroup> 175 <Compile Include="luolapaikka.png"> 176 <Name>luolapaikka</Name> 177 <Importer>TextureImporter</Importer> 178 <Processor>TextureProcessor</Processor> 179 </Compile> 180 </ItemGroup> 181 <ItemGroup> 182 <Compile Include="tausta - kasvit 2.png"> 183 <Name>tausta - kasvit 2</Name> 184 <Importer>TextureImporter</Importer> 185 <Processor>TextureProcessor</Processor> 186 </Compile> 187 </ItemGroup> 188 <ItemGroup> 189 <Compile Include="puu.png"> 190 <Name>puu</Name> 191 <Importer>TextureImporter</Importer> 192 <Processor>TextureProcessor</Processor> 193 </Compile> 194 </ItemGroup> 195 <ItemGroup> 196 <Compile Include="puuu.png"> 197 <Name>puuu</Name> 198 <Importer>TextureImporter</Importer> 199 <Processor>TextureProcessor</Processor> 200 </Compile> 201 </ItemGroup> 202 <ItemGroup> 203 <Compile Include="GUN.png"> 204 <Name>GUN</Name> 205 <Importer>TextureImporter</Importer> 206 <Processor>TextureProcessor</Processor> 207 </Compile> 208 </ItemGroup> 209 <ItemGroup> 210 <Compile Include="tähtäin.png"> 211 <Name>tähtäin</Name> 212 <Importer>TextureImporter</Importer> 213 <Processor>TextureProcessor</Processor> 214 </Compile> 215 </ItemGroup> 216 <ItemGroup> 217 <Compile Include="PistolShot.wav"> 218 <Name>PistolShot</Name> 219 <Importer>WavImporter</Importer> 220 <Processor>SoundEffectProcessor</Processor> 187 221 </Compile> 188 222 </ItemGroup> -
2015/30/SamuelL/jotain/jotain/jotainContent/kentta1.txt
r6938 r6995 5 5 6 6 7 7 # 8 8 # 9 9 #T N k K 10 10 # TT rrrrrrrrrrrrrrr 11 11 #################### 12 #################### 13 #################### 14 #################### 15 #################### 16 #################### 17 #################### 12 #################### 13 #################### 14 #################### 15 #################### 16 #################### 17 #################### 18 18 ####################VVVVVVVVVVVVVVVV -
2015/30/SamuelL/jotain/jotain/jotainContent/kentta2.txt
r6938 r6995 1 2 3 4 1 # N # 2 # # 3 ## #### 4 ### ###### 5 # ##### ##### #### ###### 6 ########### ## # ######### 7 #### 5 8 6 9 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 10 11 12 13 K p k K 14 O 15 ##############################################################
Note: See TracChangeset
for help on using the changeset viewer.