Assuming your sprites are arranged in your image like this:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
You can index them like this:
var xpixels = (spriteId%4)*50;
var ypixels = Math.floor(spriteId/4)*85;
x
and y
offsets are from the top left, so spriteId = 5
is at xpixels=50, ypixels=85
.