Sams Teach Yourself Game Programming in 24 Hours

Book description

Sams Teach Yourself Game Programming in 24 Hours demystifies game programming by providing clear, practical lessons using C/C++, the industry standard in game programming. The book focuses on the Windows API to construct games for the Windows platform and discusses game theory, including double-buffered graphics, sprite animation, and digitized sound effects and music. A fully functional game engine provides readers with the ability to create their own future games.

Table of contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. About the Technical Editor
  4. Acknowledgments
  5. We Want to Hear from You!
    1. Reader Services
  6. Introduction
  7. How This Book Is Structured
  8. What You’ll Need
  9. I. Getting Started
    1. 1. Learning the Basics of Game Creation
      1. Getting to Know Video Games
        1. Why Video Games?
        2. Types of Video Games
      2. Game Design Essentials
        1. Coming Up with the Basic Idea
        2. Putting Together the Storyline
        3. Visualizing the Graphics
        4. Developing an Ear for the Sound
        5. Dictating Game Play with the Controls
        6. Deciding on the Play Modes
      3. Object-Oriented Programming and Games
        1. Understanding OOP
        2. Applying OOP to Games
      4. Exploring the Tools of the Trade
        1. Compiler
        2. Graphics Tools
        3. Sound and Music Tools
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    2. 2. A Windows Game Programming Primer
      1. Windows Programming Essentials
        1. Event-Driven Programming
        2. Communicating with Messages
        3. Understanding Device Independence
        4. Storing Program Information as Resources
        5. Dealing with Strange Data Types
        6. Unconventional Coding Conventions
      2. Peeking Inside a Windows Program
        1. Where It All Begins
        2. The Window Class
        3. Creating a Window
        4. Handling Messages
        5. The Window Procedure
        6. Working with Resources
      3. Building the Skeleton Example Program
        1. Writing the Program Code
        2. Assembling the Resources
        3. Testing the Finished Product
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Exercises
    3. 3. Creating an Engine for Games
      1. What Is a Game Engine?
      2. Pondering the Role of a Game Engine
        1. Breaking a Game Down into Events
        2. Establishing the Timing for Games
      3. Developing a Game Engine
        1. The Game Event Functions
        2. The GameEngine Class
      4. Building the Game Skeleton Example Program
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    4. 4. Learning to Draw Basic Graphics
      1. Graphics Essentials
        1. The Graphics Coordinate System
        2. The Basics of Color
      2. Examining Graphics in Windows
        1. Working with Device Contexts
        2. Writing with Pens
        3. Painting with Brushes
        4. Drawing Images with Bitmaps
        5. Managing Color with Palettes
      3. Painting Windows
        1. Painting Text
        2. Painting Primitive Graphics
          1. Lines
          2. Rectangles
          3. Ellipses
          4. Polygons
        3. Working with Pens and Brushes
          1. Creating Pens
          2. Creating Brushes
          3. Selecting Pens and Brushes
      4. Building the Trippy Example Program
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    5. 5. Drawing Graphical Images
      1. The Basics of Bitmap Images
      2. Peeking Inside a Bitmap
      3. Developing a Bitmap Class
        1. How It Will Work
        2. Putting the Code Together
          1. The Class Definition
          2. The Constructors and Destructor
          3. Three Ways to Create a Bitmap
          4. Drawing the Bitmap
      4. Building the Slideshow Example Program
        1. Writing the Program Code
        2. Assembling the Resources
        3. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
  10. II. Interacting with Game Players
    1. 6. Controlling Games with the Keyboard and Mouse
      1. Gaming and User Input
      2. Taking a Look at User Input Devices
        1. The Keyboard
        2. The Mouse
        3. Joysticks
      3. Assessing Keyboard Input for Games
      4. Tracking the Mouse
      5. Revamping the Game Engine for Input
        1. Adding Keyboard Support
        2. Adding Mouse Support
        3. Sprucing Up the Bitmap Class
      6. Building the UFO Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      7. Summary
      8. Q&A
      9. Workshop
        1. Quiz
        2. Exercises
    2. 7. Improving Input with Joysticks
      1. Joystick Basics
      2. Calibrating Joysticks
      3. Tracking Joystick Movements
      4. Revamping the Game Engine for Joysticks
        1. Accessing Win32 Multimedia Features
        2. Developing the Joystick Code
      5. Building the UFO 2 Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Exercises
    3. 8. Example Game: Brainiac
      1. How Does the Game Play?
      2. Designing the Game
      3. Building the Game
        1. Writing the Game Code
      4. Testing the Game
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
  11. III. Animating Games with Sprites
    1. 9. A Crash Course in Game Animation
      1. What Is Animation?
        1. Animation and Frame Rate
        2. Making the Move to Computer Animation
      2. 2D Versus 3D Animation
      3. Types of 2D Animation
        1. Frame-Based Animation
        2. Cast-Based Animation
          1. Seeing Through Objects with Transparency
          2. Adding Depth with Z-Order
          3. Detecting Collisions Between Objects
      4. Applying Animation in Games
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    2. 10. Making Things Move with Sprites
      1. Evaluating the Role of Sprites in Games
      2. Designing an All-Purpose Sprite
      3. Creating the Sprite Class
        1. Creating and Destroying the Sprite
        2. Updating the Sprite
        3. Drawing the Sprite
      4. Building the Fore Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    3. 11. Managing a World of Sprites
      1. Assessing the Need for Sprite Management
      2. Designing a Sprite Manager
      3. Adding the Sprite Manager to the Game Engine
        1. Improving the Sprite Class
        2. Enhancing the Game Engine
      4. Eliminating Flicker with Double Buffering
      5. Building the Fore 2 Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Exercises
    4. 12. Example Game: Henway
      1. How Does the Game Play?
      2. Designing the Game
      3. Building the Game
        1. Writing the Game Code
      4. Testing the Game
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
  12. IV. Making Noise with Sound and Music
    1. 13. Getting Acquainted with Digital Sound and Music
      1. Understanding Digital Sound
      2. Getting to Know Windows Waves
      3. Feeling the Music with MIDI
      4. Exploring Sound Tools
        1. Sound Forge
        2. Cool Edit
      5. Creating and Editing Sounds
      6. Finding Sounds and Music
      7. Summary
      8. Q&A
      9. Workshop
        1. Quiz
        2. Exercises
    2. 14. Playing Wave Sounds
      1. Accessing Wave Sounds
      2. Playing Wave Sounds
        1. Playing a Wave from a File
        2. Playing a Wave from a Resource
        3. Looping a Wave Sound
        4. Stopping a Wave Sound
      3. Building the Brainiac 2 Program Example
        1. Writing the Program Code
        2. Assembling the Resources
        3. Testing the Finished Product
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Exercises
    3. 15. Playing MIDI Music
      1. Understanding the Windows Media Control Interface
      2. Using the MCI to Play MIDI Music
        1. Opening the MIDI Device
        2. Playing a MIDI Song
        3. Pausing a MIDI Song
        4. Closing the MIDI Device
      3. Adding MIDI Music Support to the Game Engine
      4. Building the Henway 2 Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    4. 16. Example Game: Battle Office
      1. How Does the Game Play?
      2. Designing the Game
      3. Building the Game
        1. Writing the Program Code
      4. Testing the Game
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
  13. V. Taking Animation to the Next Level
    1. 17. Animating the Appearance of Sprites
      1. Frame Animation Revisited
      2. Designing an Animated Sprite
      3. Adding Animated Sprite Support to the Game Engine
        1. Drawing Only Part of a Bitmap
        2. Animating the Sprite Class
      4. Building the Battle Office 2 Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    2. 18. Creating Backgrounds for Your Sprites
      1. Assessing the Significance of Game Backgrounds
      2. Understanding the Types of Game Backgrounds
        1. Solid Backgrounds
        2. Image Backgrounds
        3. Animated Backgrounds
        4. Scrolling Backgrounds
      3. Adding Background Support to the Game Engine
        1. Creating a Basic Background Class
        2. Creating an Animated Background Class
      4. Building the Roids Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    3. 19. Example Game: Meteor Defense
      1. How Does the Game Play?
      2. Designing the Game
      3. Enhancing Sprites in the Game Engine
      4. Building the Game
        1. Writing the Game Code
      5. Testing the Game
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Exercises
  14. VI. Adding Brains to Your Games
    1. 20. Teaching Games to Think
      1. Understanding Artificial Intelligence
      2. Exploring Types of Game AI
        1. Roaming AI
          1. Chasing
          2. Evading
          3. Patterned Roaming
        2. Behavioral AI
        3. Strategic AI
      3. Developing an AI Strategy
      4. Building the Roids 2 Program Example
        1. Writing the Program Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
    2. 21. Example Game: Space Out
      1. How Does the Game Play?
      2. Designing the Game
      3. Adding One Last Sprite Feature to the Game Engine
      4. Building the Game
        1. Writing the Game Code
      5. Testing the Game
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Exercises
  15. VII. Spicing up Your Games
    1. 22. Adding Pizzazz to Your Game with a Splash Screen
      1. The Importance of a Splash Screen
      2. Looking Behind a Splash Screen
      3. Building the Space Out 2 Game
        1. Writing the Game Code
        2. Testing the Finished Product
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Exercises
    2. 23. Showing Off Your Game with Demo Mode
      1. What Is Demo Mode?
      2. The Nuts and Bolts of Demo Mode
      3. Building the Space Out 3 Game
        1. Writing the Game Code
        2. Testing the Finished Product
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Exercises
    3. 24. Keeping Track of High Scores
      1. The Significance of Keeping Score
      2. Modeling High Score Data
      3. Storing and Retrieving High Score Data
      4. Building the Space Out 4 Game
        1. Writing the Game Code
        2. Testing the Finished Product
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Exercises
  16. VIII. Appendixes
    1. A. Quiz Answers
      1. Hour 1, “Learning the Basics of Game Creation”
      2. Hour 2, “A Windows Game Programming Primer”
      3. Hour 3, “Creating an Engine for Games”
      4. Hour 4, “Learning to Draw Basic Graphics”
      5. Hour 5, “Drawing Graphical Images”
      6. Hour 6, “Controlling Games with the Keyboard and Mouse”
      7. Hour 7, “Improving Input with Joysticks”
      8. Hour 8, “Example Game: Brainiac”
      9. Hour 9, “A Crash Course in Game Animation”
      10. Hour 10, “Making Things Move with Sprites”
      11. Hour 11, “Managing a World of Sprites”
      12. Hour 12, “Example Game: Henway”
      13. Hour 13, “Getting Acquainted with Digital Sound and Music”
      14. Hour 14, “Playing Wave Sounds”
      15. Hour 15, “Playing MIDI Music”
      16. Hour 16, “Example Game: Battle Office”
      17. Hour 17, “Animating the Appearance of Sprites”
      18. Hour 18, “Creating Backgrounds for Your Sprites”
      19. Hour 19, “Example Game: Meteor Defense”
      20. Hour 20, “Teaching Games to Think”
      21. Hour 21, “Example Game: Space Out”
      22. Hour 22, “Adding Pizzazz to Your Game with a Splash Screen”
      23. Hour 23, “Showing Off Your Game with Demo Mode”
      24. Hour 24, “Keeping Track of High Scores”
    2. B. Selecting a Game Development Tool
      1. Microsoft Visual C++
      2. Borland C++Builder
      3. Bloodshed Dev-C++
      4. DJGPP

Product information

  • Title: Sams Teach Yourself Game Programming in 24 Hours
  • Author(s):
  • Release date: December 2002
  • Publisher(s): Sams
  • ISBN: 9780672324611