Skip to content

Instantly share code, notes, and snippets.

@kitsunde
Created September 19, 2012 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsunde/3749572 to your computer and use it in GitHub Desktop.
Save kitsunde/3749572 to your computer and use it in GitHub Desktop.
Fancy movement logics.
function checkMovementOrSomething(){
var $element = $("thingy");
var movementActions = [
{target: 'wall', callback: function(game){ return false; }}
{target: 'ghost', callback: function(game){if(!game.hasPowerUp()){game.gameOver(); return false;}}},
{target: 'bubble', callback: function(game){game.points++;game.removeBubble(x, y)}}
{target: 'power-up', callback: function(game){game.setPowerUp(true);}}
];
for(var i=0; i< movementActions.length;i++){
var action = movementActions[i];
if($element.hasClass(action.target)){
if(!action.callback()) return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment