Changeset 5376
- Timestamp:
- 2014-07-03 14:58:06 (9 years ago)
- Location:
- 2014/27/MikkoL/LM2/LM2
- Files:
-
- 18 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/27/MikkoL/LM2/LM2/LM2/LM2.cs
r5288 r5376 26 26 public IntMeter ScoreValue = new IntMeter(100, 0, int.MaxValue); 27 27 public bool canShoot = false; 28 public double explosion_scale = 50; 28 29 29 30 public enemy(double width, double height) … … 62 63 Vector cntr = new Vector(0, 0); 63 64 64 bool BlazeIt = false;65 66 65 //Player 67 66 Image player_ship_01 = LoadImage("player_ship_01"); … … 69 68 //Bullets 70 69 Image bullet_green_laser01 = LoadImage("bullet_green_laser01"); 71 72 70 Image bullet_player01 = LoadImage("bullet_player"); 73 71 Image bullet_player02 = LoadImage("bullet_player02"); … … 75 73 Image bullet_player04 = LoadImage("bullet_player04"); 76 74 Image bullet_player05 = LoadImage("bullet_player05"); 75 Image bullet_enemy_01 = LoadImage("bullet_enemy_01"); 76 Image bullet_enemy_02 = LoadImage("bullet_enemy_02"); 77 77 //Enemies 78 78 Image enemy_ship_01 = LoadImage("enemy_ship_01"); 79 79 Image enemy_ship_01_red = LoadImage("enemy_ship_01_red"); 80 Image enemy_ship_01_blue = LoadImage("enemy_ship_01_blue"); 81 Image enemy_ship_01_blue_inverted = LoadImage("enemy_ship_01_blue_inverted"); 80 82 Image enemy_ship_02 = LoadImage("enemy_ship_02"); 81 Image enemy_ship_02_inverted = LoadImage("enemy_ship_02_inverted"); 83 Image enemy_ship_03 = LoadImage("enemy_ship_03"); 84 Image enemy_ship_04 = LoadImage("enemy_ship_04"); 82 85 //Powerups 83 86 Image powerup_damage = LoadImage("powerup_damage"); 84 87 Image powerup_spread = LoadImage("powerup_spread"); 88 //Backgrounds 89 Image space_bg = LoadImage("space_bg"); 90 //Explosion 91 private Animation explosion_anim; 85 92 86 93 //SFX … … 97 104 98 105 //Collision ignore groups 99 //2: player bullets 106 //2: player bullets/enemy bullets 100 107 //3: enemies 101 108 //4: powerups … … 106 113 public override void Begin() 107 114 { 115 //Load SFX 108 116 hurtsfx.Play(); 109 117 explosionsfx.Play(); … … 111 119 shootsfx.Play(); 112 120 powerupsfx.Play(); 121 //Load Anim 122 explosion_anim = LoadAnimation("explosionanim"); 113 123 114 124 SetWindowSize(1280, 800, false); … … 150 160 void CreateLevel(string level) 151 161 { 152 Level.Background.Color = Color.LightGray; 153 Timer strobeBg = new Timer(); 154 strobeBg.Interval = 0.005; 155 strobeBg.Timeout += delegate { 156 Level.Background.Color = RandomGen.NextColor(); 157 }; 158 if (BlazeIt) strobeBg.Start(); 159 162 //Level.Background.CreateStars(); 163 160 164 TileMap lvl = TileMap.FromLevelAsset(level); 161 165 lvl.SetTileMethod('x', border); … … 165 169 lvl.SetTileMethod('1', enemy_ship_1); 166 170 lvl.SetTileMethod('R', enemy_ship_1_red); 167 lvl.SetTileMethod('B', enemy_ship_2_bottom); 168 lvl.SetTileMethod('T', enemy_ship_2_top); 171 lvl.SetTileMethod('B', enemy_ship_1_bottom); 172 lvl.SetTileMethod('T', enemy_ship_1_top); 173 lvl.SetTileMethod('2', enemy_ship_2); 174 lvl.SetTileMethod('3', enemy_ship_3); 175 lvl.SetTileMethod('4', enemy_ship_4_top); 176 lvl.SetTileMethod('$', enemy_ship_4_bottom); 169 177 lvl.Execute(35, 35); 170 // 171 172 178 179 Level.Background.Color = Color.LightGray; 180 GameObject bg = new GameObject(1280, 800); 181 bg.Position = cntr; 182 bg.Image = space_bg; 183 bg.MoveTo(cntr - new Vector(1280, 0), 1000); 184 185 GameObject bg2 = new GameObject(1280, 800); 186 bg2.Position = cntr+new Vector(1280,0); 187 bg2.Image = space_bg; 188 bg2.MoveTo(cntr,1000); 189 190 Timer scroll = new Timer(); 191 scroll.Interval = 0.001; 192 scroll.Timeout += delegate 193 { 194 if (bg.Position.X <= cntr.X - 1279) 195 { 196 bg.Position = cntr; 197 bg.MoveTo(cntr - new Vector(1280, 0), 1000); 198 }; 199 if (bg2.Position.X <= cntr.X + 1) 200 { 201 bg2.Position = cntr+new Vector(1280,0); 202 bg2.MoveTo(cntr, 1000); 203 }; 204 }; 205 scroll.Start(); 206 Add(bg, -3); 207 Add(bg2, -3); 173 208 174 209 //AddPlayer(Screen.Center, 0, 0); … … 178 213 179 214 Camera.Position = player.Position; 180 //Camera.ZoomFactor = 0. 5;215 //Camera.ZoomFactor = 0.4; 181 216 //edgeBorders(); 182 217 } … … 184 219 void border(Vector position, double width, double height) 185 220 { 186 PhysicsObject border = PhysicsObject.CreateStaticObject(width, height); 187 border.Position = position; 188 border.Restitution = 0; 189 border.KineticFriction = 0; 190 border.StaticFriction = 0; 191 border.Color = Color.Black; 192 border.Tag = "border"; 193 Add(border, 1); 194 195 PhysicsObject border2 = PhysicsObject.CreateStaticObject(width*2, height); 221 PhysicsObject border2 = PhysicsObject.CreateStaticObject(width*1.5, height); 196 222 border2.Position = position; 197 223 border2.Restitution = 0; 198 224 border2.KineticFriction = 0; 199 225 border2.StaticFriction = 0; 200 border2.Color = Color. Black;226 border2.Color = Color.Lighter(Color.Black, 20); 201 227 border2.Tag = "border"; 202 Add(border2, 0); 203 204 Timer strobe = new Timer(); 205 strobe.Interval = 0.005; 206 strobe.Timeout += delegate { 207 border.Color = RandomGen.NextColor(); 208 border2.Color = RandomGen.NextColor(); 209 }; 210 if (BlazeIt) strobe.Start(); 228 Add(border2, 1); 211 229 } 212 230 void frontBorder(Vector position, double width, double height) … … 280 298 Add(player,2); 281 299 282 Timer strobePlr = new Timer();283 strobePlr.Interval = 0.005;284 strobePlr.Timeout += delegate { player.Color = RandomGen.NextColor(); };285 if (BlazeIt) strobePlr.Start();286 287 300 playership.Image = player_ship_02; 288 301 playership.IgnoresCollisionResponse = true; … … 303 316 304 317 playership.Brain = playershipbrain; 305 Add(playership, - 2);318 Add(playership, -1); 306 319 } 307 320 void AddHealthbar() 308 321 { 309 ProgressBar healthBar = new ProgressBar( 200, 10);322 ProgressBar healthBar = new ProgressBar(135, 10); 310 323 healthBar.BorderColor = Color.Black; 311 324 healthBar.Color = Color.Black; … … 313 326 healthBar.BindTo(player.health); 314 327 healthBar.Angle = Angle.RightAngle; 315 healthBar.Position = new Vector(Screen.LeftSafe + 30, Screen.BottomSafe + 2 35);328 healthBar.Position = new Vector(Screen.LeftSafe + 30, Screen.BottomSafe + 200); 316 329 Add(healthBar); 317 318 Timer strobehpBar = new Timer();319 strobehpBar.Interval = 0.005;320 strobehpBar.Timeout += delegate { healthBar.BarColor = RandomGen.NextColor(); };321 if (BlazeIt) strobehpBar.Start();322 330 } 323 331 void AddControls() … … 371 379 }; 372 380 } 373 374 381 void stopShoot() 375 382 { 376 383 wpn_timer.Stop(); 377 384 } 378 379 385 void Weapon() 380 386 { 381 387 if (wpn_spread.Value == 1) 382 388 { 383 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);384 Projectile(player.Position + new Vector(10, -5), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);389 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 0), new Vector(40, 12) ); 390 Projectile(player.Position + new Vector(10, -5), new Vector(1200, 0), new Vector(40, 12) ); 385 391 } 386 392 else if (wpn_spread.Value == 2) 387 393 { 388 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);389 Projectile(player.Position + new Vector(10, -10), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);390 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);394 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 0), new Vector(40, 12) ); 395 Projectile(player.Position + new Vector(10, -10), new Vector(1200, 0), new Vector(40, 12) ); 396 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) ); 391 397 } 392 398 else if (wpn_spread.Value == 3) 393 399 { 394 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);395 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);396 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 20), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);397 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -20), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);400 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 15), new Vector(40, 12) ); 401 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -15), new Vector(40, 12) ); 402 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 20), new Vector(40, 12) ); 403 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -20), new Vector(40, 12) ); 398 404 } 399 405 else if (wpn_spread.Value == 4) 400 406 { 401 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);402 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);403 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);404 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);405 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);407 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 25), new Vector(40, 12) ); 408 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -25), new Vector(40, 12) ); 409 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) ); 410 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) ); 411 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) ); 406 412 } 407 413 else if (wpn_spread.Value == 5) 408 414 { 409 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);410 Projectile(player.Position + new Vector(10, -0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);411 412 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);413 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);414 415 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 55), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);416 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -55), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);415 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) ); 416 Projectile(player.Position + new Vector(10, -0), new Vector(1200, 0), new Vector(40, 12) ); 417 418 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) ); 419 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) ); 420 421 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 55), new Vector(40, 12) ); 422 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -55), new Vector(40, 12) ); 417 423 } 418 424 else if (wpn_spread.Value == 6) 419 425 { 420 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);421 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);422 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);423 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);424 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);425 426 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);427 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);426 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) ); 427 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12) ); 428 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) ); 429 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) ); 430 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) ); 431 432 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 75), new Vector(40, 12) ); 433 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -75), new Vector(40, 12) ); 428 434 } 429 435 else if (wpn_spread.Value == 7) 430 436 { 431 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);432 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);433 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);434 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);435 436 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);437 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);438 439 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);440 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);437 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 15), new Vector(40, 12) ); 438 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -15), new Vector(40, 12) ); 439 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 15), new Vector(40, 12) ); 440 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -15), new Vector(40, 12) ); 441 442 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12) ); 443 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12) ); 444 445 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) ); 446 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) ); 441 447 } 442 448 else if (wpn_spread.Value == 8) 443 449 { 444 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);445 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);446 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);447 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);448 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);449 450 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);451 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);452 453 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);454 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);450 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) ); 451 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) ); 452 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12) ); 453 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 25), new Vector(40, 12) ); 454 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -25), new Vector(40, 12) ); 455 456 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 50), new Vector(40, 12) ); 457 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -50), new Vector(40, 12) ); 458 459 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) ); 460 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) ); 455 461 } 456 462 else if (wpn_spread.Value == 9) 457 463 { 458 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);459 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);460 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);461 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -15), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);462 463 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);464 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);465 466 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);467 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);468 469 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);470 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);464 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 15), new Vector(40, 12)); 465 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -15), new Vector(40, 12)); 466 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 15), new Vector(40, 12)); 467 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -15), new Vector(40, 12)); 468 469 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12)); 470 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12)); 471 472 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 50), new Vector(40, 12)); 473 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -50), new Vector(40, 12)); 474 475 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 75), new Vector(40, 12)); 476 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -75), new Vector(40, 12)); 471 477 } 472 478 else if (wpn_spread.Value == 10) 473 479 { 474 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);475 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);476 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);477 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);478 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);479 480 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);481 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -75), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);482 483 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 100), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);484 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -100), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);485 486 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 125), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);487 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -125), new Vector(40, 12) , Color.LightBlue, "bullet", Shape.Rectangle);488 } 489 } 490 void Projectile(Vector pos, Vector vel, Vector size , Color color, string type, Shape shape)480 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 25), new Vector(40, 12) ); 481 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -25), new Vector(40, 12)); 482 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 0), new Vector(40, 12)); 483 Projectile(player.Position + new Vector(10, 0), new Vector(1200, 50), new Vector(40, 12)); 484 Projectile(player.Position + new Vector(10, -0), new Vector(1200, -50), new Vector(40, 12) ); 485 486 Projectile(player.Position + new Vector(10, 5), new Vector(1200, 75), new Vector(40, 12) ); 487 Projectile(player.Position + new Vector(10, -5), new Vector(1200, -75), new Vector(40, 12) ); 488 489 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 100), new Vector(40, 12) ); 490 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -100), new Vector(40, 12) ); 491 492 Projectile(player.Position + new Vector(10, 10), new Vector(1200, 125), new Vector(40, 12) ); 493 Projectile(player.Position + new Vector(10, -10), new Vector(1200, -125), new Vector(40, 12) ); 494 } 495 } 496 void Projectile(Vector pos, Vector vel, Vector size) 491 497 { 492 498 bullet projectile = new bullet(size.X, size.Y); 493 499 projectile.Shape = Shape.Diamond; 494 projectile.Color = color;495 500 projectile.IgnoresGravity = true; 496 501 projectile.Position = pos; … … 502 507 else if (wpn_damageRatio.Value <= 8) projectile.Image = bullet_player02; 503 508 else if (wpn_damageRatio.Value <= 10) projectile.Image = bullet_player05; 504 if (BlazeIt) projectile.Image = null; 509 505 510 projectile.damage = wpn_damageRatio.Value; 506 511 projectile.IgnoresCollisionResponse = true; … … 513 518 AddCollisionHandler<bullet, enemy>(projectile, damageEnemy); 514 519 515 Add(projectile, -2);520 Add(projectile, 0); 516 521 projectile.Hit(vel / 1.5); 517 522 projectile.Angle = projectile.Velocity.Angle; 518 519 520 Timer strobe = new Timer();521 strobe.Interval = 0.005;522 strobe.Timeout += delegate {523 projectile.Color = RandomGen.NextColor();524 if (projectile.IsDestroyed) strobe.Stop();525 };526 if (BlazeIt) strobe.Start();527 523 } 528 524 … … 539 535 enemyship.Image = enemy_ship_01; 540 536 541 Add(enemyship );537 Add(enemyship, -1); 542 538 enemyship.Hit(stagespeed); 543 539 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); … … 559 555 enemyship.CollisionIgnoreGroup = 3; 560 556 561 Add(enemyship );557 Add(enemyship, -1); 562 558 enemyship.Hit(stagespeed); 563 559 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); … … 576 572 }; 577 573 } 578 void enemy_ship_ 2_bottom(Vector pos, double width, double height)579 { 580 enemy enemyship = new enemy(3 0, 70);574 void enemy_ship_1_bottom(Vector pos, double width, double height) 575 { 576 enemy enemyship = new enemy(35, 70); 581 577 enemyship.Shape = Shape.Circle; 582 578 enemyship.Color = Color.Black; … … 585 581 enemyship.CollisionIgnoreGroup = 3; 586 582 enemyship.health.MaxValue = 6; 587 enemyship.Image = enemy_ship_0 2;583 enemyship.Image = enemy_ship_01_blue; 588 584 enemyship.Angle = Angle.FromDegrees(90); 589 585 590 Add(enemyship );586 Add(enemyship, -1); 591 587 enemyship.Hit(stagespeed); 592 588 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); 593 AddCollisionHandler<PhysicsObject, frontborder>(enemyship, enemy_ship_ 2_bottom_frontborder);594 } 595 void enemy_ship_ 2_bottom_frontborder(PhysicsObject enemyship, frontborder br)589 AddCollisionHandler<PhysicsObject, frontborder>(enemyship, enemy_ship_1_bottom_frontborder); 590 } 591 void enemy_ship_1_bottom_frontborder(PhysicsObject enemyship, frontborder br) 596 592 { 597 593 enemyship.LifetimeLeft = TimeSpan.FromSeconds(3); … … 600 596 enemyship.Position = new Vector(cntr.X + enemyship.Y, -405); 601 597 } 602 void enemy_ship_ 2_top(Vector pos, double width, double height)603 { 604 enemy enemyship = new enemy(3 0, 70);598 void enemy_ship_1_top(Vector pos, double width, double height) 599 { 600 enemy enemyship = new enemy(35, 70); 605 601 enemyship.Shape = Shape.Circle; 606 602 enemyship.Color = Color.Black; … … 609 605 enemyship.CollisionIgnoreGroup = 3; 610 606 enemyship.health.MaxValue = 6; 611 enemyship.Image = enemy_ship_0 2_inverted;607 enemyship.Image = enemy_ship_01_blue_inverted; 612 608 enemyship.Angle = Angle.FromDegrees(90); 613 609 614 Add(enemyship );610 Add(enemyship, -1); 615 611 enemyship.Hit(stagespeed); 616 612 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); 617 AddCollisionHandler<PhysicsObject, frontborder>(enemyship, enemy_ship_ 2_top_frontborder);618 } 619 void enemy_ship_ 2_top_frontborder(PhysicsObject enemysship, frontborder br)613 AddCollisionHandler<PhysicsObject, frontborder>(enemyship, enemy_ship_1_top_frontborder); 614 } 615 void enemy_ship_1_top_frontborder(PhysicsObject enemysship, frontborder br) 620 616 { 621 617 enemysship.LifetimeLeft = TimeSpan.FromSeconds(3); … … 625 621 enemysship.Position = new Vector(cntr.X + enemysship.Y, 405); 626 622 } 623 void enemy_ship_2(Vector pos, double widht, double height) 624 { 625 enemy enemyship = new enemy(70, 30); 626 enemyship.Shape = Shape.Circle; 627 enemyship.Color = Color.Black; 628 enemyship.Position = pos; 629 enemyship.IgnoresCollisionResponse = true; 630 enemyship.CollisionIgnoreGroup = 3; 631 enemyship.health.MaxValue = 12; 632 enemyship.Image = enemy_ship_02; 633 634 Add(enemyship, -1); 635 enemyship.Hit(stagespeed); 636 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); 637 AddCollisionHandler<enemy, frontborder>(enemyship, enemy_ship_2_start_shooting); 638 } 639 void enemy_ship_2_start_shooting(enemy enemyship, frontborder border) 640 { 641 if (!enemyship.canShoot) 642 { 643 enemyship.canShoot = true; 644 645 enemyship.Velocity = enemyship.Velocity / 2; 646 647 double angle = 0; 648 double i = 1; 649 double c = 0; 650 UnlimitedAngle angle2; 651 652 Timer shoot = new Timer(); 653 shoot.Interval = 0.01; 654 shoot.Timeout += delegate 655 { 656 if (c >= 200) shoot.Stop(); 657 else if (c != 200) 658 { 659 if (!enemyship.IsDestroyed) 660 { 661 angle = angle + i; 662 i = i + 0.1; 663 c++; 664 angle2 = UnlimitedAngle.FromDegrees(angle); 665 enemy_shoot_2(enemyship.Position, 666 667 angle2.GetVector() * 500 668 ); 669 } 670 else shoot.Stop(); 671 }; 672 673 }; 674 675 Timer wait = new Timer(); 676 wait.Interval = 0.5; 677 wait.Timeout += delegate 678 { 679 if (!enemyship.IsDestroyed) shoot.Start(); 680 else wait.Stop(); 681 }; 682 wait.Start(1); 683 } 684 } 685 void enemy_ship_3(Vector pos, double width, double height) 686 { 687 enemy enemyship = new enemy(71, 56); 688 enemyship.Shape = Shape.Circle; 689 enemyship.Position = pos; 690 enemyship.IgnoresCollisionResponse = true; 691 enemyship.CollisionIgnoreGroup = 3; 692 enemyship.health.MaxValue = 40; 693 enemyship.Image = enemy_ship_03; 694 enemyship.explosion_scale = 75; 695 696 Add(enemyship,-1); 697 enemyship.Hit(stagespeed); 698 699 AddCollisionHandler<enemy, frontborder>(enemyship, enemy_ship_3_start_shooting); 700 AddCollisionHandler<enemy, player>(enemyship,damagePlayerEnemyShip2); 701 } 702 void enemy_ship_3_start_shooting(enemy enemyship, frontborder border) 703 { 704 if (!enemyship.canShoot) 705 { 706 enemyship.canShoot = true; 707 enemyship.LifetimeLeft = TimeSpan.FromSeconds(60); 708 enemyship.Velocity = enemyship.Velocity / 3; 709 int i = 0; 710 int e = 0; 711 712 Timer wait = new Timer(); 713 714 Timer enemy_shoot = new Timer(); 715 enemy_shoot.Interval = 0.02; 716 enemy_shoot.Timeout += delegate 717 { 718 if (e >= 4) 719 { 720 enemy_shoot.Stop(); 721 enemyship.Velocity = stagespeed / 3; 722 enemyship.LifetimeLeft = TimeSpan.FromSeconds(6); 723 }; 724 i++; 725 if (i == 50 && e != 4) 726 { 727 enemy_shoot.Stop(); 728 wait.Start(1); 729 e++; 730 }; 731 if (enemyship.IsDestroyed) enemy_shoot.Stop(); 732 if (e != 4) enemy_shoot_1(enemyship.Position + new Vector(RandomGen.NextDouble(-30, 30), RandomGen.NextDouble(-30, 30))); 733 }; 734 735 wait.Interval = 0.5; 736 wait.Timeout += delegate 737 { 738 if (enemyship.IsDestroyed) wait.Stop(); 739 i = 0; 740 enemy_shoot.Start(50); 741 }; 742 743 Timer enemy_start = new Timer(); 744 enemy_start.Interval = 3; 745 enemy_start.Timeout += delegate 746 { 747 if (!enemyship.IsDestroyed) 748 { 749 enemy_shoot.Start(50); 750 enemyship.Velocity = new Vector(0,0); 751 }; 752 }; 753 enemy_start.Start(1); 754 755 }; 756 } 757 void enemy_ship_4_top(Vector pos, double width, double height) 758 { 759 enemy enemyship = new enemy(43, 33); 760 enemyship.Shape = Shape.Circle; 761 enemyship.Color = Color.Black; 762 enemyship.Position = pos; 763 enemyship.IgnoresCollisionResponse = true; 764 enemyship.CollisionIgnoreGroup = 3; 765 enemyship.health.MaxValue = 10; 766 enemyship.Image = enemy_ship_04; 767 768 Add(enemyship, -1); 769 enemyship.Hit(stagespeed); 770 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); 771 AddCollisionHandler<enemy, frontborder>(enemyship, enemy_ship_4_top_frontborder); 772 } 773 void enemy_ship_4_top_frontborder(enemy enemysship, frontborder br) 774 { 775 if (!enemysship.canShoot) 776 { 777 enemysship.canShoot = true; 778 779 //enemysship.LifetimeLeft = TimeSpan.FromSeconds(3); 780 enemysship.Velocity = new Vector(0, stagespeed.X); 781 enemysship.Position = new Vector(cntr.X + enemysship.Y, 405); 782 783 Timer chk = new Timer(); 784 chk.Interval = 0.01; 785 chk.Timeout += delegate 786 { 787 if (!enemysship.IsDestroyed) 788 { 789 if (enemysship.Y >= player.Y - 10 && enemysship.Y <= player.Y + 10) 790 { 791 enemysship.Velocity = stagespeed; 792 if ((player.X - enemysship.X) > 0) enemysship.Velocity = -stagespeed; 793 chk.Stop(); 794 enemysship.LifetimeLeft = TimeSpan.FromSeconds(3); 795 } 796 } 797 else if (enemysship.IsDestroyed) chk.Stop(); 798 }; 799 800 chk.Start(); 801 }; 802 } 803 void enemy_ship_4_bottom(Vector pos, double width, double height) 804 { 805 enemy enemyship = new enemy(43, 33); 806 enemyship.Shape = Shape.Circle; 807 enemyship.Color = Color.Black; 808 enemyship.Position = pos; 809 enemyship.IgnoresCollisionResponse = true; 810 enemyship.CollisionIgnoreGroup = 3; 811 enemyship.health.MaxValue = 10; 812 enemyship.Image = enemy_ship_04; 813 814 Add(enemyship, -1); 815 enemyship.Hit(stagespeed); 816 AddCollisionHandler<enemy, player>(enemyship, damagePlayerEnemyShip); 817 AddCollisionHandler<enemy, frontborder>(enemyship, enemy_ship_4_bottom_frontborder); 818 } 819 void enemy_ship_4_bottom_frontborder(enemy enemysship, frontborder br) 820 { 821 if (!enemysship.canShoot) 822 { 823 enemysship.canShoot = true; 824 enemysship.Velocity = new Vector(0, -stagespeed.X); 825 enemysship.Position = new Vector(cntr.X + enemysship.Y, -405); 826 827 Timer chk = new Timer(); 828 chk.Interval = 0.01; 829 chk.Timeout += delegate 830 { 831 if (!enemysship.IsDestroyed) 832 { 833 if (enemysship.Y >= player.Y - 10 && enemysship.Y <= player.Y + 10) 834 { 835 enemysship.Velocity = stagespeed; 836 if ((player.X - enemysship.X) > 0) enemysship.Velocity = -stagespeed; 837 chk.Stop(); 838 enemysship.LifetimeLeft = TimeSpan.FromSeconds(3); 839 } 840 } 841 else if (enemysship.IsDestroyed) chk.Stop(); 842 }; 843 844 chk.Start(); 845 }; 846 } 847 848 849 void enemy_shoot_1(Vector pos) 850 { 851 bullet enemy_bullet = new bullet(27, 27); 852 enemy_bullet.Shape = Shape.Circle; 853 enemy_bullet.Position = pos; 854 enemy_bullet.IgnoresCollisionResponse = true; 855 enemy_bullet.CollisionIgnoreGroup = 2; 856 enemy_bullet.damage = 10; 857 enemy_bullet.MaximumLifetime = TimeSpan.FromSeconds(5); 858 enemy_bullet.Image = bullet_enemy_01; 859 860 enemy_bullet.Hit((player.Position - enemy_bullet.Position).Normalize() * 300); 861 Add(enemy_bullet, 0); 862 AddCollisionHandler<bullet, player>(enemy_bullet, damagePlayerBullet); 863 } 864 865 void enemy_shoot_2(Vector pos, Vector dir) 866 { 867 bullet enemy_bullet = new bullet(27, 27); 868 enemy_bullet.Shape = Shape.Circle; 869 enemy_bullet.Position = pos; 870 enemy_bullet.IgnoresCollisionResponse = true; 871 enemy_bullet.CollisionIgnoreGroup = 2; 872 enemy_bullet.damage = 10; 873 enemy_bullet.MaximumLifetime = TimeSpan.FromSeconds(5); 874 enemy_bullet.Image = bullet_enemy_02; 875 876 Add(enemy_bullet, 0); 877 enemy_bullet.Hit(dir/9); 878 AddCollisionHandler<bullet, player>(enemy_bullet, damagePlayerBullet); 879 880 Timer wait = new Timer(); 881 wait.Interval = 0.8; 882 wait.Timeout += delegate 883 { 884 enemy_bullet.Velocity = dir; 885 }; 886 wait.Start(1); 887 } 627 888 628 889 //Power-ups 629 890 void powerup(Vector pos) 630 891 { 631 int a = RandomGen.NextInt(1, 10);892 int a = RandomGen.NextInt(1, 20); 632 893 if (a == 1) 633 894 { … … 689 950 b.Destroy(); 690 951 hurtsfx.Play(); 952 explosionsfx.Play(); 953 explosion_animation(b); 954 } 955 void damagePlayerEnemyShip2(enemy b, player p) 956 { 957 p.health.Value = p.health.Value - 10; 958 hurtsfx.Play(); 691 959 } 692 960 void damagePlayerBullet(bullet b, player p) … … 703 971 powerup(e.Position); 704 972 explosionsfx.Play(); 973 explosion_animation(e); 705 974 }; 706 975 hitsfx.Play(); … … 708 977 709 978 } 979 void explosion_animation(enemy enemyship) 980 { 981 GameObject explosion = new GameObject(enemyship.explosion_scale, enemyship.explosion_scale); 982 explosion.Position = enemyship.Position; 983 explosion.Animation = explosion_anim; 984 explosion.MaximumLifetime = TimeSpan.FromSeconds(0.2); 985 Add(explosion,-1); 986 explosion.Animation.Start(1); 987 } 710 988 } -
2014/27/MikkoL/LM2/LM2/LM2Content/LM2Content.contentproj
r5288 r5376 109 109 </ItemGroup> 110 110 <ItemGroup> 111 <Compile Include="enemy_ship_02_inverted.png">112 <Name>enemy_ship_02_inverted</Name>113 <Importer>TextureImporter</Importer>114 <Processor>TextureProcessor</Processor>115 </Compile>116 </ItemGroup>117 <ItemGroup>118 111 <Compile Include="powerup_damage.png"> 119 112 <Name>powerup_damage</Name> … … 187 180 <Importer>WavImporter</Importer> 188 181 <Processor>SoundEffectProcessor</Processor> 182 </Compile> 183 </ItemGroup> 184 <ItemGroup> 185 <Compile Include="enemy_ship_01_blue.png"> 186 <Name>enemy_ship_01_blue</Name> 187 <Importer>TextureImporter</Importer> 188 <Processor>TextureProcessor</Processor> 189 </Compile> 190 <Compile Include="enemy_ship_01_blue_inverted.png"> 191 <Name>enemy_ship_01_blue_inverted</Name> 192 <Importer>TextureImporter</Importer> 193 <Processor>TextureProcessor</Processor> 194 </Compile> 195 </ItemGroup> 196 <ItemGroup> 197 <Compile Include="enemy_ship_03.png"> 198 <Name>enemy_ship_03</Name> 199 <Importer>TextureImporter</Importer> 200 <Processor>TextureProcessor</Processor> 201 </Compile> 202 </ItemGroup> 203 <ItemGroup> 204 <Compile Include="bullet_enemy_01.png"> 205 <Name>bullet_enemy_01</Name> 206 <Importer>TextureImporter</Importer> 207 <Processor>TextureProcessor</Processor> 208 </Compile> 209 </ItemGroup> 210 <ItemGroup> 211 <Compile Include="explosionanim.anim"> 212 <Name>explosionanim</Name> 213 <Importer>AnimationImporter</Importer> 214 <Processor>AnimationContentProcessor</Processor> 215 </Compile> 216 </ItemGroup> 217 <ItemGroup> 218 <Compile Include="space_bg.png"> 219 <Name>space_bg</Name> 220 <Importer>TextureImporter</Importer> 221 <Processor>TextureProcessor</Processor> 222 </Compile> 223 </ItemGroup> 224 <ItemGroup> 225 <Compile Include="bullet_enemy_02.png"> 226 <Name>bullet_enemy_02</Name> 227 <Importer>TextureImporter</Importer> 228 <Processor>TextureProcessor</Processor> 229 </Compile> 230 </ItemGroup> 231 <ItemGroup> 232 <Compile Include="enemy_ship_04.png"> 233 <Name>enemy_ship_04</Name> 234 <Importer>TextureImporter</Importer> 235 <Processor>TextureProcessor</Processor> 189 236 </Compile> 190 237 </ItemGroup> -
2014/27/MikkoL/LM2/LM2/LM2Content/level_test.txt
r5288 r5376 4 4 % 5 5 % 6 reuna % T6 reuna % 7 7 % 8 8 % … … 21 21 & % 22 22 & % 23 & P % 23 & P % 3 24 24 & % 25 25 & % … … 36 36 % 37 37 % 38 % 39 % 40 % 41 reuna % T38 % 39 % 40 % 41 reuna % 42 42 % 43 43 %
Note: See TracChangeset
for help on using the changeset viewer.