main game logic