var speed = mouseX/30;
var amountOfFrames = 24;
var currentFrame = Math.round(counter*speed) % amountOfFrames;
var spriteRows = 8; // HOW MANY
var sprite = Math.floor(mouseY/canvas.height * spriteRows);
var stripWidth = img1.width;
var stripHeight = img1.height;
var frameWidth = stripWidth/amountOfFrames;
var frameHeight = stripHeight / spriteRows;
var sx = currentFrame * frameWidth;
var sy = sprite * frameHeight;
var x = mouseX;
var y = mouseY;
var w = frameWidth;
var h = frameHeight;
context.drawImage(img1,sx,sy,frameWidth,frameHeight,x,y,w,h);