BEYO

var speed = mouseX/30;

var amountOfFrames = 17;

var currentFrame = Math.round(counter*speed) % amountOfFrames;

var stripWidth = img1.width;
var stripHeight = img1.height;

var frameWidth = stripWidth/amountOfFrames;
var frameHeight = 150;

var sx = currentFrame * frameWidth;
var sy = 0;

var x = mouseX;
var y = mouseY;
var w = frameWidth;
var h = frameHeight;

context.drawImage(img1,sx,sy,frameWidth,frameHeight,x,y,w,h);