Creating an Engine for Games for Windows - Testing the Finished Product
(Page 11 of 11 )
When you run the Blizzard example, you are presented with a game screen that rapidly fills up with snowflake icons, as shown in Figure 2.2.

Figure 2.2. The Blizzard example demonstrates how the game engine makes it possible to focus solely on the game-specific aspects of a Windows program.
It doesn't take too long for the Blizzard screen to fill up with snowflake icons. This has a lot to do with the fact that you have the game set up so that it runs through 15 game cycles per second. You could dramatically slow down or speed up the icons being drawn by altering the frame rate of the game in the GameInitialize() function.
Another interesting point to make about the Blizzard example is how it isn't smart enough to repaint the snowflake icons if the window gets invalidated, as shown in Figure 2.3. In other words, if you minimize the program or activate another window in front of it, the game screen will get cleared. This happens because the GamePaint() function doesn't have any code to redraw the snowflake icons in response to the game screen needing a repaint. The repaint problem in the Blizzard example is addressed in the next chapter when you explore Windows graphics in more detail.

Figure 2.3. The timing aspect of the game engine causes the Blizzard example to fill up quite quickly with randomly placed Blizzard icons.
Summary
This chapter took an important leap forward in your game development path by guiding you through the design and development of a basic game engine for Windows games. You learned about the importance of a game engine, as well as what code goes into creating a fully functioning game engine. Although features certainly need to be added to the game engine to make it more useful in the context of games, the elements are in place for creating Windows games with much less effort than if you didn't create the engine. It's okay if you don't yet fully appreciate the role of the game engine in making your life easier as a game programmer. But trust me; you will eventually come to appreciate the game engine for how it simplifies game development and allows you to focus on the most important facets of game design.
Chapter 3, "Learning to Draw Basic Graphics," explains the mysteries behind the graphics code that you saw in the Blizzard example. You learn some of the fundamental graphics techniques that will carry you forward throughout the rest of the book. You also create a pretty neat example that demonstrates your new graphics knowledge.
Extreme Game Makeover
Many of the chapters throughout the book contain this section, which includes ideas about how to improve upon the program examples and games. You might be thinking that the Blizzard example is about as limited as an example can be, but part of an "extreme makeover" is showing how to turn one thing into something unexpectedly different. In the case of the Blizzard example, you can turn it into a uniquely different program by changing the snowflake icon and the manner in which the icon is drawn in the GameCycle() function. Just follow these steps:
Modify the Blizzard.ico and Blizzard_sm.ico to a completely different theme, such as a fireball.
Add a POINT global variable to the program that is used to "remember" the position of the fireball; this position can initially be randomly calculated.
Each time through the GameCycle() function, alter the position of the fireball so that it appears to move in a particular direction over time.
The end result of these changes is a program that shows a fireball gracefully moving across the screen leaving trails of fire, as opposed to randomly appearing snowflakes.
This chapter is from Beginning Game Programming, by Michael Morrison (Sams, ISBN: 0672326590). Check it out at your favorite bookstore today.
Buy this book now. |
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |