ActionScript & Flash
ActionScript game primer: a grid and a moving player
A maze-style game is easier to build when the board is data. Store walls and open cells in a grid, then map a cell to pixels only when drawing. The movement rule can check the destination cell before changing the player’s position.
Begin with one player and no enemies. Keep the current direction separate from the next requested direction so an early key press can take effect at the next junction. This produces smoother control than requiring input at an exact pixel.
Once movement works, add collectible cells and a clear completion rule. Enemies should follow the same grid boundaries. Test corners, blocked turns and restarts before adding animation or sound.
Try the idea
var nextColumn:int = column + directionX;
var nextRow:int = row + directionY;
if (nextRow >= 0 && nextRow < rows &&
nextColumn >= 0 && nextColumn < columns &&
grid[nextRow][nextColumn] != WALL) {
column = nextColumn; row = nextRow;
}