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

Note: The following links to a JavaScript file if you want to view code just click on view source.

https://s3-us-west-2.amazonaws.com/m...formgame2.html