I have stored my map, but the problem I am having is displaying it. My map is 100x100 tiles which are 40x40px.
I have my loop running through the array but I'm having difficulty selecting the portion of the map image to relate to the tiles. This is the code which selects the portion of the image on each iteration:
var sx = Math.floor(tileId % 8 * tileWidth); //source x
var sy = Math.floor(tileId / 8 * tileHeight); //source y
I'm using Canvas and keep getting this error message:
INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value.
I'm guessing the remainder or division by 8 is wrong, this is something I picked up from the net, but what exactly does that integer need to be?
Thanks