Factored out the game update and render process to a function