3. The Game Loop and Menus

The game loop is often called the heartbeat of a computer game, and indeed it is what gives life to our games. As a game is being played, inputs to the game, status, and outputs all need to proceed in a regular cycle. The game loop is the implementation of that cycle, so an efficient, high-performance game loop is essential for a playable computer game.

Game Loops in General

Computer games are all based on a cycle of operations. The typical steps in such a cycle include the following actions:

• Acquire input from the player.

• Update the game status as a result of user input.

• Update the game status as a result of time.

• Check for collisions among objects.

• Update objects based on game physics.

• Update the user ...

Get Learning Android Game Programming: A Hands-On Guide to Building Your First Android Game now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.