Skip to content

Instantly share code, notes, and snippets.

@sh78
Last active June 7, 2018 20:14
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 sh78/8c52b61f6bbbfa02dcd0f71124112bd1 to your computer and use it in GitHub Desktop.
Save sh78/8c52b61f6bbbfa02dcd0f71124112bd1 to your computer and use it in GitHub Desktop.
window.onload = function(){
c = document.getElementById("myCanvas");
cc = c.getContext("2d");
setInterval(update, 1000/30);
};
var c = document.getElementById("myCanvas");
var cacX1 = 960;
var dy = document.getElementById("myCanvas").height - 60;
var speed = -1;
var drop = -7;
function update(){
// drawBack();
// drawCac();
drawDino();
}
c.addEventListener( "keydown", function(e){
if(dy >= c.height - 70){
dy = 10;
drawDino();
console.log("up");
}
}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment