Implementing user interaction within a game loop