jonoxia/platform-game — Issue #19: Implement obstacle API
Author: jonoxia
Created: 2011-10-26 22:00:19+00:00
State: open

Any object in the world other than the start location, goal, or basic block is called an Obstacle
even though some of them may actually be helpful.

Defining one with an imaginary ideal API might look something like this:

DefineObstacle( {
name: "Springboard",
sprite: "http://some/site/springboard.png",
// size = 1 block by 1 block unless overridden
onContactPlayer: function(obstacle, player, contactDirection) {
if (contactDirection == "top") {
player.bounce();
}
if (player.buttonPressed("jump")) {
player.boostSpeed(0, -50);
}
},

onMove: function(obstacle, world, tick) {
// default is to do nothing, but moving platforms could move themselves for instance
}
});