Javascript canvas collision detection
I'm building a game in Javascript using canvas which requires collision detection, in this case if the player sprite hits a box, the player must not be allowed through the box. I have a global array called blockList that holds all the boxes being drawn to the canvas. It looks like this: var blockList = [[50, 400, 100, 100]]; And they're being drawn to the canvas like this: c.fillRect(blockList[0][0], blockList[0][1], blockList[0][2], blockList[0][3]); I also have a player object, which has an update method and a draw method. Update sets the position of the player based on keyboard input etc,