I am creating a new \"whack-a-mole\" style game where the children have to hit the correct numbers in accordance to the question. So far it is going really well, I have a timer,
You can approach this problem in at least two ways (these two are popped up in my head).
Note: read this article for further information: http://eloquentjavascript.net/chapter8.html
var _grids;
var GRID_SIZE = 20 //a constant holding the panel size;
function createGrids() {
_grids = new Array();
for (var i = 0; i< stage.stageWidth / GRID_SIZE; i++) {
_grids[i] = new Array();
for (var j = 0; j< stage.stageHeight / GRID_SIZE; j++) {
_grids[i][j] = new Array();
}
}
}
Then on a separate function to create the collision check. I've created a gist for collision check in Actionscript, but you can use the same principle in Javascript too. I've created this gist for inspirational purposes.