- Timestamp:
- 2010-07-09 13:07:37 (13 years ago)
- Location:
- 2010/27/jomiilri/Duel
- Files:
-
- 8 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/jomiilri/Duel/Content/Content.contentproj
r1196 r1237 74 74 </Compile> 75 75 </ItemGroup> 76 <ItemGroup> 77 <Compile Include="Go on %28You can%29.mp3"> 78 <Name>Go on %28You can%29</Name> 79 <Importer>Mp3Importer</Importer> 80 <Processor>SongProcessor</Processor> 81 </Compile> 82 </ItemGroup> 83 <ItemGroup> 84 <Compile Include="scream_hyva.wav"> 85 <Name>scream_hyva</Name> 86 <Importer>WavImporter</Importer> 87 <Processor>SoundEffectProcessor</Processor> 88 </Compile> 89 </ItemGroup> 90 <ItemGroup> 91 <Compile Include="rifle_single_shot1.wav"> 92 <Name>rifle_single_shot1</Name> 93 <Importer>WavImporter</Importer> 94 <Processor>SoundEffectProcessor</Processor> 95 </Compile> 96 </ItemGroup> 76 97 </Project> -
2010/27/jomiilri/Duel/Peli.cs
r1196 r1237 21 21 const int ruudunKorkeus = 32; 22 22 23 SoundEffect ampumaAani; 24 25 23 26 protected override void Begin() 24 27 { 28 MediaPlayer.Play("Go on (You can)"); 29 ampumaAani = LoadSoundEffect("rifle_single_shot1"); 30 25 31 konekivaari1 = new AssaultRifle(20, 5); 26 32 konekivaari2 = new AssaultRifle(20, 5); … … 38 44 LuoAmmusLaskuri1(); 39 45 LuoAmmusLaskuri2(); 40 46 LuoAmmusLaatikkoAjastin(); 47 48 Camera.ZoomToLevel(); 41 49 42 50 AloitaPeli(); 43 51 44 IsFullScreen = true;52 SetWindowSize(1024, 768, false); 45 53 46 54 p1 = LuoHahmo1(); 47 55 p1.LinearDamping = 0.95; 48 56 p1.Restitution = 0.05; 49 p1.X = Screen.Left + 975;50 p1.Y = Screen.Top - 760;57 p1.X = Level.Right - 115; 58 p1.Y = Level.Top - 600; 51 59 Add(p1); 52 60 … … 54 62 p2.LinearDamping = 0.95; 55 63 p2.Restitution = 0.05; 56 p2.X = Screen.Left + 305;57 p2.Y = Screen.Top - 260;64 p2.X = Level.Left + 115; 65 p2.Y = Level.Top - 105; 58 66 Add(p2); 59 67 … … 65 73 GameObject alareuna = Level.CreateBottomBorder(); 66 74 GameObject ylareuna = Level.CreateTopBorder(); 75 GameObject vasenreuna = Level.CreateLeftBorder(); 76 GameObject oikeareuna = Level.CreateRightBorder(); 67 77 alareuna.Image = LoadImage("tausta1"); 68 78 ylareuna.Image = LoadImage("tausta1"); 79 vasenreuna.Image = LoadImage("tausta1"); 80 oikeareuna.Image = LoadImage("tausta1"); 69 81 70 82 Level.Background.Image = LoadImage("taustakuva1"); 71 83 Level.Background.FitToLevel(); 72 73 Camera.ZoomToLevel();74 84 } 75 85 … … 125 135 void LuoOhjaimet() 126 136 { 137 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null); 138 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, null); 139 140 127 141 Keyboard.Listen(Key.Left, ButtonState.Down, KaannaPelaajaa, null, 3, p1); 128 142 Keyboard.Listen(Key.Right, ButtonState.Down, KaannaPelaajaa, null, -3, p1); … … 137 151 ControllerOne.Listen(Button.DPadUp, ButtonState.Released, PysaytaPelaaja, null, p1); 138 152 ControllerOne.Listen(Button.DPadDown, ButtonState.Down, LiikutaPelaajaaTaakse, null, p1); 139 ControllerOne.Listen(Button. A, ButtonState.Down, Ammu, "Ammu", p1, konekivaari1);153 ControllerOne.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", p1, konekivaari1); 140 154 141 155 Keyboard.Listen(Key.A, ButtonState.Down, KaannaPelaajaa, null, 3, p2); … … 144 158 Keyboard.Listen(Key.W, ButtonState.Released, PysaytaPelaaja, null, p2); 145 159 Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaaTaakse, null, p2); 146 Keyboard.Listen(Key. F, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2);160 Keyboard.Listen(Key.LeftControl, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 147 161 148 162 ControllerTwo.Listen(Button.DPadLeft, ButtonState.Down, KaannaPelaajaa, null, 3, p2); … … 151 165 ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, PysaytaPelaaja, null, p2); 152 166 ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, LiikutaPelaajaaTaakse, null, p2); 153 ControllerTwo.Listen(Button. A, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2);167 ControllerTwo.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 154 168 } 155 169 … … 157 171 { 158 172 PhysicsObject ammus = ase.Shoot(); 159 if (ammus != null) ammus.Tag = ampuja; 173 if (ammus != null) 174 { 175 ammus.Tag = ampuja; 176 } 177 //MediaPlayer.Play("rifle_single_shot"); 178 ampumaAani.Play(); 160 179 } 161 180 … … 178 197 elamaLaskuri1.Value = elamaLaskuri1.Value - 4; 179 198 } 180 181 199 if (seina.Tag.ToString() == "p1") 200 { 182 201 elamaLaskuri2.Value = elamaLaskuri2.Value - 4; 183 } 184 luoti.Destroy(); 202 } 203 luoti.Destroy(); 204 205 if (elamaLaskuri1.Value <= 0) 206 { 207 PelaajaKuolee(1); 208 } 209 210 if (elamaLaskuri2.Value <= 0) 211 { 212 PelaajaKuolee(2); 213 } 185 214 } 186 215 … … 192 221 193 222 Label elamaNaytto1 = new Label(); 194 elamaNaytto1.X = Screen.Left + 100;195 elamaNaytto1.Y = Screen.Top - 980;223 elamaNaytto1.X = Level.Left + 100; 224 elamaNaytto1.Y = Level.Bottom - 5; 196 225 elamaNaytto1.TextColor = Color.Red; 197 226 … … 205 234 206 235 Label elamaNaytto2 = new Label(); 207 elamaNaytto2.X = Screen.Right - 100;208 elamaNaytto2.Y = Screen.Top - 980;236 elamaNaytto2.X = Level.Right - 100; 237 elamaNaytto2.Y = Level.Bottom - 5; 209 238 elamaNaytto2.TextColor = Color.Red; 210 239 … … 216 245 { 217 246 Label ammusNaytto1 = new Label(); 218 ammusNaytto1.X = Screen.Left + 200;219 ammusNaytto1.Y = Screen.Top - 980;247 ammusNaytto1.X = Level.Left + 200; 248 ammusNaytto1.Y = Level.Bottom - 5; 220 249 ammusNaytto1.TextColor = Color.Black; 221 250 … … 227 256 { 228 257 Label ammusNaytto2 = new Label(); 229 ammusNaytto2.X = Screen.Right - 200;230 ammusNaytto2.Y = Screen.Top - 980;258 ammusNaytto2.X = Level.Right - 200; 259 ammusNaytto2.Y = Level.Bottom - 5; 231 260 ammusNaytto2.TextColor = Color.Black; 232 261 … … 239 268 PhysicsObject ammusLaatikko = new PhysicsObject(18, 12); 240 269 ammusLaatikko.Image = LoadImage("ammuslaatikko1"); 241 Add(ammusLaatikko); 242 AddCollisionHandler(ammusLaatikko, LisaaAmmuksia); 270 //Add(ammusLaatikko); 271 AddCollisionHandler(ammusLaatikko, LisaaAmmuksia); 272 ammusLaatikko.IgnoresCollisionResponse = true; 243 273 return ammusLaatikko; 244 274 } 245 275 246 void LisaaAmmuksia(PhysicsObject ammusLaatikko, PhysicsObject pelaaja) 247 { 248 if (konekivaari1.Ammo.Value == 250) return; 249 else 276 void LisaaAmmuksia(PhysicsObject ammusLaatikko, PhysicsObject kohde) 277 { 278 if (kohde == p1 && konekivaari1.Ammo.Value < 250) 250 279 { 251 280 konekivaari1.Ammo.Value += 50; 252 281 ammusLaatikko.Destroy(); 253 282 } 254 255 } 256 257 void LuoAmmusLaatikkoAjastint() 283 if (kohde == p2 && konekivaari2.Ammo.Value < 250) 284 { 285 konekivaari2.Ammo.Value += 50; 286 ammusLaatikko.Destroy(); 287 } 288 } 289 290 void LuoAmmusLaatikkoAjastin() 258 291 { 259 292 ammusAjastin = new Timer(); 260 ammusAjastin.Interval = 40;293 ammusAjastin.Interval = 10; 261 294 ammusAjastin.Trigger += LisaaAmmusLaatikoita; 262 295 Add(ammusAjastin); … … 268 301 { 269 302 PhysicsObject laatikko = LuoAmmusLaatikko(); 270 laatikko.X = RandomGen.NextDouble(Screen.Left + 100, Screen.Left - 900); 271 laatikko.Y = RandomGen.NextDouble(Screen.Top + 100, Screen.Top - 900); 303 laatikko.X = RandomGen.NextDouble(Level.Left + 50, Level.Right - 50); 304 laatikko.Y = RandomGen.NextDouble(Level.Top - 50, Level.Bottom + 50); 305 Add(laatikko); 306 } 307 308 void PelaajaKuolee(int kumpiPelaaja) 309 { 310 if (kumpiPelaaja == 1) 311 { 312 PlaySound("scream_hyva"); 313 Timer kuolemaAj = KuolemaAjastin(); 314 kuolemaAj.Trigger += SiirraPelaaja1Alkuun; 315 //p2.Destroy(); 316 p1.IsVisible = false; 317 NollaaLaskurit(); 318 } 319 else 320 { 321 PlaySound("scream_hyva"); 322 Remove(p1); 323 } 324 325 NollaaLaskurit(); 326 } 327 328 void SiirraPelaaja1Alkuun(Timer sender) 329 { 330 p1.IsVisible = true; 331 p1.X = Level.Left + 115; 332 p1.Y = Level.Top - 105; 333 sender.Stop(); 334 335 } 336 337 void SiirraPelaaja2Alkuun(Timer sender) 338 { 339 p2.IsVisible = true; 340 p2.X = Level.Left + 115; 341 p2.Y = Level.Top - 105; 342 //Add(p2); 343 } 344 345 void NollaaLaskurit() 346 { 347 elamaLaskuri1.Value = 100; 348 elamaLaskuri2.Value = 100; 349 // Aseitten Ammo myös täyteen... 350 351 } 352 353 Timer KuolemaAjastin() 354 { 355 Timer kuolemaAjastin = new Timer(); 356 kuolemaAjastin.Interval = 3; 357 //kuolemaAjastin.Trigger += SiirraPelaajaAlkuun; 358 Add(kuolemaAjastin); 359 kuolemaAjastin.Start(); 360 return kuolemaAjastin; 272 361 } 273 362 } -
2010/27/jomiilri/Duel/TextFile1.txt
r1196 r1237 1 1 IIIIIIIIIIIIIIIIIIIIIIIIIIII 2 2 IIIIIIIIIIIIIIIIIIIIIIIIIIII 3 II R I II 4 II I II 3 II I I II 4 II I I II 5 II IIIIIII IIIIII II 6 II I I II 7 II I I II 8 II I I II 9 II IIII IIII II 10 II I I II 5 11 II II 6 12 II II 7 II II 8 II II 9 II II 10 II II 11 II II 12 II II 13 II II 14 II II 15 II II 16 II II 17 II II 18 II II 19 II I II 20 II ** I P II 13 II I I II 14 II IIII IIII II 15 II I I II 16 II I I II 17 II I I II 18 II IIIIIII IIIIII II 19 II I I II 20 II I I II 21 21 IIIIIIIIIIIIIIIIIIIIIIIIIIII 22 22 IIIIIIIIIIIIIIIIIIIIIIIIIIII
Note: See TracChangeset
for help on using the changeset viewer.