AaronG

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. What I want to do is make it so if the player touches the enemy from the side then the player either loses a life and or it causes the game to be over. But if the player jumps on top of the enemy then it causes that enemy to disappear. If a the player touches an enemy then the player loses a life which is done by running this code... this.status = "lost"; this.finishDelay = 1; How ever if the player jumps on the enemy then the enemy dies which is done by running this code... this.actors = this.actors.filter(function(other) { return other != actor; }); Here is my code so far... Level.prototype.playerTouched = function(type, actor) { } else if (type == "lava" && this.status == null && player.y == enemy.y) { this.status = "lost"; this.finishDelay = 1; } else if (type == "coin" && player.y > enemy.y) { this.actors = this.actors.filter(function(other) { return other != actor; }); } }; The part that I am having trouble with is... when the player touches the enemy while the player is on the ground (the players y axis is equal to the enemys y axis)... player.y == enemy.y and when the player jumps on top of the enemy. (the players y axis is greater then the enemys y axis)... player.y > enemy.y My total code is posted as an attachment platformgame2.html