Put the game loop inside a function, Added a reset button