Skip to content

Instantly share code, notes, and snippets.

@malleor
Last active August 29, 2015 13:57
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 malleor/9513275 to your computer and use it in GitHub Desktop.
Save malleor/9513275 to your computer and use it in GitHub Desktop.
function play(iteration) {
var ctrl = {
up: function() { window.gm.inputManager.emit('move', 0); return window.gm.moved; },
right: function() { window.gm.inputManager.emit('move', 1); return window.gm.moved; },
down: function() { window.gm.inputManager.emit('move', 2); return window.gm.moved; },
left: function() { window.gm.inputManager.emit('move', 3); return window.gm.moved; }
};
while(!window.gm.over && !window.gm.won) {
if(!iteration(ctrl)) {
break;
}
}
}
function start() {
window.gm.restart();
}
window.gm = new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
play(function(ctrl) {
return ctrl.up() || ctrl.left() || ctrl.up() || ctrl.right();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment