Skip to content

Instantly share code, notes, and snippets.

@jpbyrne
Created April 11, 2013 18:37
Show Gist options
  • Save jpbyrne/5365992 to your computer and use it in GitHub Desktop.
Save jpbyrne/5365992 to your computer and use it in GitHub Desktop.
var ctx;
var count = 0;
var x;
var y;
var img = new Image();
img.src = "sprite_sheet.png";
img.onload = draw;
function draw() {
requestAnimationFrame(draw);
ctx.clearRect(0,0,212,201);
x = (count % 9)* 212;
y = Math.floor(count /9) * 201;
ctx.drawImage(img, x, y, 212, 201, 0,0, 212,201);
if(count== 149)
count= 0
else
count++
}
function init() {
tx = document.getElementById("canvas").getContext("2d");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment