simple game logic put in to javascript game