Chapter 2. Game Engine Anatomy

To solve the large problem of how to create a game on the iPhone, we first need to solve a series of smaller problems such as how to display graphics and play sounds. These are problems associated with building parts of a game engine. And just like the human body, each part of a game engine is different but vital. Thus begins our chapter on game engine anatomy. We will discuss each major part of a game engine, including the application framework, state machine, graphics engine, physics engine, audio engine, player input, and game logic.

Writing a serious game is a big task that involves a lot of code. It is important to design that code in an organized fashion from the start, rather than adding bits and pieces over time. When building a house, an architect creates blueprints for the whole house, which the contractors then build. However, many programmers who are new to game programming build one part of the “house” from a tutorial, and add each “room” piece by piece as they learn. It’s no surprise when the end result is bad.

Figure 2-1 shows the structure of a game engine that works well for most games. By understanding all of the parts of a game engine and how they work together, we can design the whole game at the start, and build our application the “Right Way.” In the following sections, we’ll cover each part of Figure 2-1:

  • Application framework

  • Game state manager

  • Graphics engine

Figure 2-1. Functional structure of a game engine ...

Get iPhone Game Development 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.