Skip to content

Instantly share code, notes, and snippets.

@nickstewart95
Created December 19, 2016 17:03
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 nickstewart95/b0c4c3366c31abee2ecc2366edfd84c8 to your computer and use it in GitHub Desktop.
Save nickstewart95/b0c4c3366c31abee2ecc2366edfd84c8 to your computer and use it in GitHub Desktop.
function animate(data) {
var animateTop = 1040;
var top = Math.round((1040 / 6) * data[0]);
var left = fixLeft(data[1]);
var move = setInterval(function(){
for (var i = 0; i < 2; i++) {
context.save();
animateTop = animateTop - 1;
context.clearRect(left, (animateTop + 1), 200, 200);
context.restore();
if (data[2] == 1) {
context.drawImage(player1Balloon, left, animateTop, 200, 200);
} else {
context.drawImage(player2Balloon, left, animateTop, 200, 200);
}
if(animateTop === top) {
checkSolutions();
clearTimeout(move);
}
}
}, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment