Home > Articles

Creating an Engine for Games

  • Print
  • + Share This
This chapter is from the book

A game is a specialized type of program, but it is still just a program written in a programming language. This means that you can create a game just as you would any other Windows program, such as the Skeleton application you saw in Hour 2, "A Windows Game Programming Primer." However, certain game-specific tasks must be carried out in all games. Therefore, it would be quite helpful to organize the code in your games so that the game-specific code is isolated from the general Windows application code. In isolating this code, it might also be useful to build in some cool features that apply solely to games. The idea I'm suggesting is that of a game engine, which is a grouping of program code that performs tasks common to games. This lesson guides you through the design and development of a game engine that you'll build on throughout the remainder of the book.

In this hour, you'll learn:

  • The importance of a game engine in game development

  • How to design and develop a basic game engine for Windows game programming

  • How to create an example program that demonstrates the power of the game engine

What Is a Game Engine?

Think about a few different games you like, and try to think of them in terms of how they might be designed under the hood. More importantly, see if you can figure out any common design elements that would apply to all the games. For example, do all the games have a background, a title screen, and background music? If so, it's possible that they are designed around the concept of a game engine. Game engines are particularly useful in situations in which you plan on creating more than one game, and you don't want to have to reinvent the wheel each time around. The idea is that you figure out what common functionality all games use, and you write it once and stick it in the game engine.

Another significant benefit of a game engine for Windows games is that it allows you to hide the messy details of Windows-specific code that doesn't necessarily have anything to do with a game. For example, most of the code you saw in the previous lesson has nothing to do with a game, but it's required of every Windows application. Rather than have you cut and paste this generic code to create a new game, I prefer hiding it in a game engine where you never have to fool with it again. You have an understanding of how it works, and you know it's there, but by not having to look at it you're free to focus on the more important and fun parts of your game code.

In case you're wondering, there's nothing magical or mysterious about a game engine. A game engine represents an organization of the code for a game so that general application tasks are separated from game-specific tasks. The benefit to the game developer is that you can add features to a game engine that you will be able to reuse in all of your future games. Additionally, using a game engine allows you to simplify the code for your games and focus your attention on the game code that matters most. Once you get accustomed to using a game engine, you'll wonder how games could be created any other way. In reality, most commercial game developers do have their own custom game engines that they've developed over years of learning what common features most games require.

  • + Share This
  • 🔖 Save To Your Account