Creating grid based game in Javascript