hw2 game logic