Commits

Jake Albano committed 8787333

Fixed enemy obstacle avoidance;
Fixed RangeError bug when one enemy was left and a projectile was going offscreen;

  • Participants
  • Parent commits 46227f5

Comments (0)

Files changed (2)

 			addEnemy(170, 320);
 			addEnemy(30, 280);
 			addEnemy(310, 250);		
-			addEnemy(640, 250);	
+			addEnemy(640, 250);
+			addEnemy(1000, 400);
 			
 			addWall(250, 375, false);
-			addWall(450, 350, false);
+			addWall(475, 350, false);
 			addWall(170, 320, false);
 			addWall(30, 280, false);
 			addWall(310, 250, false);
 		
 		private function enterFrame(e:Event):void
 		{
+			
 			if (Input.isKeyDown(Input.LEFT))
 			{
 				man.x -= 7;
 				man.rotationY = 180;
 			}
+			
 			if (Input.isKeyDown(Input.RIGHT))
 			{
 				man.x += 7;
 			{
 				for (var l:int = Mobs.length - 1; l >= 0; l--)
 				{
+					var removed:Boolean = false;
+					
 					if (Projectiles.length > 0)
 					{						
 						for (var k:int = Projectiles.length - 1; k >= 0; k--) 
 									stage.removeChild(Mobs[l]);
 									Mobs.splice(l, 1);
 									trace("hit");
-									continue;
+									
+									removed = true;
+									
+									break;
 								}
 							}
 						}
 					}
+					
+					if (removed) break;
 				}	
 			}
 			

File src/ifrit/Enemy.as

 			var found:Boolean = false;
 			for (var i:int = 0; i < Game.Platforms.length; i++) 
 			{
-				if (Game.Platforms[i].collide(this))
+				if (Game.Platforms[i].collide(this) && Game.Platforms[i].rotation == 0)
 				{
 					leftBound = Game.Platforms[i].x + this.width / 2 - Game.Platforms[i].width / 2;
 					rightBound = Game.Platforms[i].x - this.width / 2 + Game.Platforms[i].width / 2;
 					found = true;
+					break;
 				}
 			}
 			
 			
 			this.lastPosition.x = this.x;
 			
-			if (heading) this.x += 1 + speed;  else x -= 1 + speed;
+			if (heading) this.x += 1;  else x -= 1;
 		}
 		
 	}