You are previewing C# Game Programming: For Serious Game Creation.
O'Reilly logo
C# Game Programming: For Serious Game Creation

Book Description

Even experienced game developers sometimes have a hard time making their vision for a great game a reality. The number of available programming languages, libraries, and production methods can make the development process overwhelming and result in complicated, unreliable game code. C# Game Programming: For Serious Game Creation shows programmers how to write simple, clean, and reliable code step-by-step through the creation of a basic game. The game is built using C#, a high-level programming language, and OpenGL, an industry favorite for graphics display. You'll get an overview of the methods and libraries used to build good games, learn how to use those libraries and create your own, and finally build your own scrolling shooter game. You'll even find tips and information on how to develop your own game ideas and you'll have an excellent code base to work with. C# Game Programming: For Serious Game Creation provides you with all the information you need to take your game ideas from concept to completion.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. CD-ROM Downloads
  5. I. Background
    1. 1. The History of C#
      1. C# Basics
        1. Versions of C#
          1. C# 2.0
            1. Generics
            2. Anonymous Delegates
          2. C# 3.0
            1. LINQ
            2. Lambda Functions
            3. Object Initializers
            4. Collection Initializers
            5. Local Variable Type Inference and Anonymous Types
          3. C# 4.0
            1. Dynamic Objects
            2. Optional Parameters and Named Arguments
      2. Summary
    2. 2. Introducing OpenGL
      1. Architecture of OpenGL
        1. Vertices—The Building Blocks of 3D Graphics
        2. The Pipeline
      2. OpenGL Is Changing
        1. OpenGL ES
        2. WebGL
      3. OpenGL and the Graphics Card
        1. Shaders—Programs on the Graphics Card
      4. The Tao Framework
      5. Summary
    3. 3. Modern Methods
      1. Pragmatic Programming
        1. Game Programming Traps
        2. KISS
        3. DRY
          1. C++
        4. Source Control
          1. Using Source Control
        5. Unit Testing
          1. Test Driven Development
          2. Unit Testing in C#
      2. Summary
  6. II. Implementation
    1. 4. Setup
      1. Introducing Visual Studio Express—A Free IDE for C#
        1. A Quick Hello World
        2. Visual Studio Express Tips
          1. Automatic Refactoring and Code Generation
            1. Renaming
            2. Creating Functions
            3. Separating Chunks of Code
          2. Shortcuts
      2. Subversion, an Easy Source Control Solution
        1. Where to Get It
        2. Installation
        3. Creating the Repository
        4. Adding to the Repository
        5. History
        6. Extending Hello World
      3. Tao
      4. NUnit
        1. Using NUnit with a Project
        2. Running Tests
        3. An Example Project
      5. Summary
    2. 5. The Game Loop and Graphics
      1. How Do Games Work?
        1. A Closer Look at the Game Loop
      2. Implementing a Fast Game Loop in C#
        1. Adding High-Precision Timing
      3. Graphics
        1. Full Screen Mode
        2. Rendering
          1. Clearing the Background
          2. Vertices
          3. Triangles
          4. Coloring and Spinning the Triangle
      4. Summary
    3. 6. Game Structure
      1. The Basic Pattern of a Game Object
      2. Handling Game State
      3. Game State Demo
      4. Setting the Scene with Projections
        1. Form Size and OpenGL Viewport Size
        2. Aspect Ratio
        3. The Projection Matrix
        4. 2D Graphics
      5. Sprites
        1. Positioning the Sprite
        2. Managing Textures with DevIl
        3. Textured Sprites
        4. Alpha Blending Sprites
        5. Color Modulating Sprites
        6. A Sprite and Renderer Class
        7. Using the Sprite Class
    4. 7. Rendering Text
      1. Font Textures
      2. Font Data
        1. Parsing the Font Data
        2. Using the CharacterData
      3. Rendering Text
        1. Calculating the FPS
        2. V-Sync and Frame-Rate
        3. Profiling
      4. Refining the Text Class
      5. Faster Rendering with glDrawArrays
        1. Modifying the Renderer
        2. Profiling the Batch Draw Method
      6. Summary
    5. 8. Game Math
      1. Trigonometric Functions
        1. Plotting a Graph
        2. Trigonometric Functions for Special Effects
      2. Vectors
        1. What Is a Vector?
        2. The Length Operation
        3. Vector Equality
        4. Vector Addition, Subtraction, and Multiplication
        5. Normal Vectors
        6. The Dot Product Operation
        7. The Cross-Product Operation
        8. Finishing Touches to the Vector Structure
      3. Two-Dimensional Intersection
        1. Circles
        2. Rectangles
      4. Tweens
        1. An Overview of Tweening
        2. The Tween Class
        3. Using Tweens
      5. Matrices
        1. What Is a Matrix?
        2. The Identity Matrix
        3. Matrix-Matrix and Vector-Matrix Multiplication
        4. Translating and Scaling
        5. Rotation
        6. Inverse
        7. Matrix Operations on Sprites
        8. Modifying the Sprite to Use Matrices
        9. Optimization
    6. 9. Making the Game Engine
      1. A New Game Engine Project
      2. Extending the Game Engine
        1. Using the Game Engine in a Project
        2. Multiple Textures
      3. Adding Sound Support
        1. Creating Sound Files
        2. Developing a SoundManager
      4. Improving Input
        1. Wrapping Game Controllers
        2. Adding Better Mouse Support
        3. Adding Keyboard Support
    7. 10. A Simple Side-Scrolling Shooting Game
      1. A Simple Game
      2. The First Implementation Pass
        1. The Start Menu State
        2. The Inner Game State
        3. The Game Over State
      3. Developing the Inner Game
        1. Moving the Player Character
        2. Faking Movement with a Scrolling Background
        3. Adding Some Simple Enemies
        4. Introducing Simple Weapons
        5. Damage and Explosions
        6. Managing Explosions and Enemies
        7. Level Definitions
        8. Enemy Movement
        9. Enemy Attacks
      4. Continuing Iterations
    8. 11. Creating Your Own Game
      1. Project Management
      2. Display Methods
        1. 2D Games
        2. 3D Games
      3. Types of Games
        1. Text Games
        2. Puzzle Games
        3. First-Person Shooter Games
        4. Strategy Games
        5. Role-Playing Games
          1. Roguelike Games
          2. Tile-Based Role-Playing Games
          3. 3D Role-Playing Games
        6. Platform Games
      4. Final Words
  7. A. Recommended Reading
    1. The Practice of Programming
      1. The Pragmatic Programmer: From Journeyman to Master (ISBN 0-201-61622-X) by Andrew Hunt and David Thomas
      2. Code Complete Second Edition: A Practical Handbook of Software Construction (ISBN-13: 978-0735619678) by Steve McConnell
    2. The C# Language and Software Architecture
      1. CLR via C#, 3rd Edition (ISBN-13: 978-0735627048) by Jeffrey Richter
      2. Head First Design Patterns (ISBN-13: 978-0596007126) by Eric T Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra
    3. Math and Graphics Programming
      1. 3D Math Primer for Graphics and Game Development (ISBN-13: 978-1556229114) by Fletcher Dunn and Ian Parberry
      2. Computer Graphics: Principles and Practice in C (2nd Edition) (ISBN-13: 978-0201848403) by James D. Foley, Andries van Dam, Steven K. Feiner, and John F. Hughes
    4. OpenGL
      1. OpenGL Programming Guide: The Official Guide to Learning OpenGL (ISBN-13: 978-0321552624) by Dave Shreiner
      2. OpenGL Shading Language 3rd Edition by Randi J. Rost, Bill Licea-Kane, Dan Ginsburg, John M. Kessenich, Barthold Lichtenbelt, Hugh Malan, and Mike Weiblen