Code Examples
  Home arrow Code Examples arrow Page 11 - Creating an Engine for Games for Windows
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Creating an Engine for Games for Windows
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 43
    2004-10-13

    Table of Contents:
  • Creating an Engine for Games for Windows
  • What is a Game Engine?
  • Breaking a Game Down into Events
  • Developing a Game Engine
  • The GameEngine Class
  • Source Code for the WinMain Function
  • Initializing Variables
  • HandleEvent Method
  • Put the Engine to Work
  • Resource.h Header File
  • Testing the Finished Product

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    Morrison

    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.

    Morrison

    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:

    1. Modify the Blizzard.ico and Blizzard_sm.ico to a completely different theme, such as a fireball.

    2. 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.

    3. 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.

    SamsThis 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.

       · I haven't read it yet, but only by the title i love it !when i've read it i'll...
     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek