- Timestamp:
- 2011-07-01 11:43:56 (12 years ago)
- Location:
- 2011/26/HenriH
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/HenriH/Alien Empire/Alien Empire/Alien Empire/Peli.cs
r2369 r2403 21 21 Image plasma_ammus1 = LoadImage("plasma"); 22 22 Image plasma_ammus2 = LoadImage("plasma2"); 23 23 24 AssaultRifle Plasma1; 24 25 AssaultRifle Plasma2; … … 28 29 // TODO: Kirjoita ohjelmakoodisi tähän 29 30 Valikko(); 30 31 IsFullScreen = true; 32 Camera.ZoomToLevel(); 33 Level.Background.FitToLevel(); 34 31 35 } 32 36 … … 39 43 Level.Background.Image = taustakuva; 40 44 Level.Background.FitToLevel(); 41 Camera.ZoomToLevel(); 42 45 Camera.StayInLevel = true; 43 46 Label kohta1 = new Label("Aloita uusi peli"); 44 47 kohta1.Position = new Vector(0, -80); … … 82 85 ClearAll(); 83 86 // Tähän tulee kaikki kentän luomiset ym. alustukset... 84 87 85 88 Camera.ZoomToLevel(); 89 Level.Background.FitToLevel(); 86 90 Level.Background.Image = taustakuva2; 87 Level.Background.FitToLevel(); 88 Level.CreateBorders(); 91 Level.CreateBorders(0.5, false); 89 92 alus1 = new PhysicsObject(50.0, 50.0); 90 93 alus1.Tag = "Alus1"; 91 94 MediaPlayer.Play("5am-tausta"); 95 92 96 alus1.X = 300; 93 97 alus1.Y = 150; 94 98 95 99 alus1.Image = olionkuva; 96 100 97 101 alus1.AngularDamping = 0.50; 98 102 99 103 alus1.Restitution = 0.2; 100 104 101 105 alus1.CollisionIgnoreGroup = 1; 102 106 laskuri3(); 107 laskuri4(); 103 108 LuoLaskuri(); 104 109 LuoLaskuri1(); … … 113 118 Plasma2.ProjectileCollision = AmmusOsui2; 114 119 rajahdys = new ExplosionSystem(LoadImage("special"), 150); 115 Add(rajahdys);116 117 120 Add(rajahdys); 121 122 118 123 119 124 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); … … 126 131 Keyboard.Listen(Key.W, ButtonState.Released, ajaalus2, null, alus2); 127 132 Keyboard.Listen(Key.D, ButtonState.Down, kaannaalus4, "Käännä alusta Oikealle.", alus2); 128 Keyboard.Listen(Key.Right Shift, ButtonState.Down, AmmuAseella, "Ammu pelaajan 1 asetta", Plasma1, alus1);129 Keyboard.Listen(Key. LeftShift, ButtonState.Down, AmmuAseella2, "Ammu Pelaajan 2 asetta", Plasma2, alus2);130 131 132 133 Keyboard.Listen(Key.RightControl, ButtonState.Down, AmmuAseella, "Ammu pelaajan 1 asetta", Plasma1, alus1); 134 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella2, "Ammu Pelaajan 2 asetta", Plasma2, alus2); 135 136 137 133 138 } 134 139 void kiihdytaalus(PhysicsObject alus) … … 146 151 { 147 152 alus.Angle += Angle.FromDegrees(5); 148 153 149 154 } 150 155 void kaannaalus2(PhysicsObject alus) … … 157 162 } 158 163 159 164 void kaannaalus4(PhysicsObject alus2) 160 165 { 161 166 alus2.Angle -= Angle.FromDegrees(5); … … 175 180 PhysicsObject ammus = Plasma1.Shoot(); 176 181 177 182 178 183 179 184 if (ammus != null) … … 187 192 } 188 193 194 195 189 196 void AmmusOsui(PhysicsObject Ammus, PhysicsObject kohde) 190 197 { 191 198 if (kohde.Tag.ToString() == "Alus2") 192 199 { 193 rajahdys.AddEffect(Ammus.Position, 20);194 elamalaskuri2.Value -= 10;195 } 196 197 if (elamalaskuri 2.Value<=0)200 rajahdys.AddEffect(Ammus.Position, 20); 201 elamalaskuri1.Value -= 10; 202 } 203 204 if (elamalaskuri1.Value <= 0) 198 205 { 199 206 200 207 Remove(alus2); 201 elamalaskuri 2.Value = 100;202 // LuoAlus2();208 elamalaskuri1.Value = 100; 209 //Add(alus2); 203 210 Timer.SingleShot(3.0, ajastinlaukesi); 204 kuolemalaskuri.Value -= 1; 211 kuolemalaskuri1.Value -= 1; 212 if (kuolemalaskuri1.Value <= 0) 213 { 214 Lopputeksti1(); 215 } 205 216 } 206 217 … … 229 240 { 230 241 rajahdys.AddEffect(Ammus.Position, 20); 231 elamalaskuri 1.Value -= 10;232 } 233 234 if (elamalaskuri 1.Value <= 0)242 elamalaskuri2.Value -= 10; 243 } 244 245 if (elamalaskuri2.Value <= 0) 235 246 { 236 247 237 248 Remove(alus1); 238 elamalaskuri1.Value = 100; 249 elamalaskuri2.Value = 100; 250 //Add(alus2); 239 251 Timer.SingleShot(3.0, ajastinlaukesi2); 252 kuolemalaskuri2.Value -= 1; 253 if (kuolemalaskuri2.Value <= 0) 254 { 255 Lopputeksti2(); 256 } 240 257 } 241 258 242 259 Ammus.Destroy(); 243 260 } 244 245 261 262 246 263 IntMeter elamalaskuri2; 247 264 … … 255 272 pisteNaytto.TextColor = Color.White; 256 273 257 274 258 275 pisteNaytto.BindTo(elamalaskuri2); 259 276 Add(pisteNaytto); … … 262 279 { 263 280 alus2 = new PhysicsObject(50.0, 50.0); 264 alus2.Tag = "Alus2"; 281 alus2.Tag = "Alus2"; 265 282 alus2.X = 150; 266 283 alus2.Y = 300; … … 307 324 Add(alus1); 308 325 } 309 310 IntMeter kuolemalaskuri; 326 IntMeter kuolemalaskuri1; 311 327 312 328 void laskuri3() 313 329 { 314 kuolemalaskuri = new IntMeter(5);330 kuolemalaskuri1 = new IntMeter(5); 315 331 316 332 Label pisteNaytto = new Label(); … … 318 334 pisteNaytto.Y = Screen.Top - 100; 319 335 pisteNaytto.TextColor = Color.White; 320 321 pisteNaytto.BindTo(kuolemalaskuri); 336 pisteNaytto.BindTo(kuolemalaskuri1); 322 337 Add(pisteNaytto); 323 324 if (kuolemalaskuri.Value <= 0) 325 { 326 Lopputeksti1(); 327 }} 328 void Lopputeksti1() 329 { 330 Level.Background.Image = taustakuva; 331 Label tekstikentta = new Label(50.0, 20.0, "Pelaaja 1, sinä voitit! Pelaaja 2, hävisit, olet surkea."); 338 } 339 IntMeter kuolemalaskuri2; 340 341 void laskuri4() 342 { 343 kuolemalaskuri2 = new IntMeter(5); 344 345 Label pisteNaytto = new Label(); 346 pisteNaytto.X = Screen.Right - 50; 347 pisteNaytto.Y = Screen.Top - 100; 348 pisteNaytto.TextColor = Color.White; 349 pisteNaytto.BindTo(kuolemalaskuri2); 350 Add(pisteNaytto); 351 352 353 354 } 355 void Lopputeksti1() 356 { 357 ClearAll(); 358 359 IsFullScreen = true; 360 Level.Background.Image = taustakuva; 361 Level.Background.FitToLevel(); 362 Camera.StayInLevel = true; 363 Camera.ZoomToLevel(); 364 Label tekstikentta = new Label("Pelaaja 1, sinä voitit! Pelaaja 2, hävisit, olet surkea."); 365 tekstikentta.Color = Color.Transparent; 366 tekstikentta.TextColor = Color.White; 367 tekstikentta.BorderColor = Color.Transparent; 368 tekstikentta.Font = Font.DefaultLargeBold; 369 370 Label kohta1 = new Label("Aloita uusi peli"); 371 kohta1.Position = new Vector(0, -80); 372 Add(kohta1); 373 374 Label kohta2 = new Label("Lopeta"); 375 kohta2.Position = new Vector(0, -160); 376 Add(kohta2); 377 378 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 379 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 380 381 if (Mouse.IsCursorOn(kohta1)) 382 { 383 kohta1.TextColor = Color.Red; 384 } 385 else 386 { 387 kohta1.TextColor = Color.White; 388 kohta1.Font = Font.DefaultLargeBold; 389 390 if (Mouse.IsCursorOn(kohta2)) 391 { 392 kohta2.TextColor = Color.Red; 393 } 394 else 395 { 396 kohta2.TextColor = Color.White; 397 kohta2.Font = Font.DefaultLargeBold; 332 398 Add(tekstikentta); 333 399 } 334 } 400 401 } 402 } 403 404 void Lopputeksti2() 405 { 406 ClearAll(); 407 408 409 410 Level.Background.Image = taustakuva; 411 Camera.ZoomToLevel(); 412 Camera.StayInLevel = true; 413 Label tekstikentta = new Label("Pelaaja 2, sinä voitit! Pelaaja 1, hävisit, olet surkea."); 414 tekstikentta.Color = Color.Transparent; 415 tekstikentta.TextColor = Color.White; 416 tekstikentta.BorderColor = Color.Transparent; 417 tekstikentta.Font = Font.DefaultLargeBold; 418 419 Label kohta1 = new Label("Aloita uusi peli"); 420 kohta1.Position = new Vector(0, -80); 421 Add(kohta1); 422 423 Label kohta2 = new Label("Lopeta"); 424 kohta2.Position = new Vector(0, -160); 425 Add(kohta2); 426 427 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 428 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 429 430 431 if (Mouse.IsCursorOn(kohta1)) 432 { 433 kohta1.TextColor = Color.Red; 434 } 435 else 436 { 437 kohta1.TextColor = Color.White; 438 kohta1.Font = Font.DefaultLargeBold; 439 440 if (Mouse.IsCursorOn(kohta2)) 441 { 442 kohta2.TextColor = Color.Red; 443 } 444 else 445 { 446 kohta2.TextColor = Color.White; 447 kohta2.Font = Font.DefaultLargeBold; 448 Add(tekstikentta); 449 450 } 451 } 452 } 453 } 454 455 456 457 335 458 -
2011/26/HenriH/Alien Empire/Alien Empire/Alien EmpireContent/Alien EmpireContent.contentproj
r2302 r2403 195 195 </Compile> 196 196 </ItemGroup> 197 <ItemGroup> 198 <Compile Include="5am-tausta.mp3"> 199 <Name>5am-tausta</Name> 200 <Importer>Mp3Importer</Importer> 201 <Processor>SongProcessor</Processor> 202 </Compile> 203 </ItemGroup> 197 204 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 198 205 <!-- 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.