Game Programming 101

Educator Resources

Course:

Game Programming 101

Difficulty:

Intermediate

Pre-requisites:

3D Graphics 101 (recommended)

Description:

Fundamentals of Game Programming

Activity:

Game Programming using C and OpenGL

Projects:

Design and Develop a Game

Software:

3D Game Builder (Windows platform only)

Available for:

Windows PC, "netbook" or tablet

Delivery:

On-line or off-line (contact us)

Learning Outcomes

  • Game Programming using C programming language
  • 2D and 3D Graphics Programming using OpenGL
  • Matrix functions control view and object locations
  • Arrays can be used to manage multiple objects
  • Targeting and collisions require distance calculation
  • Game pad / controller state needs to be checked every frame
  • Game speed should to be syncronised with time
  • Model matrix is used to locate and rotate objects
  • Angles are converted to x,y using cosine and sine
  • Limits must be applied to objects to keep them on screen
  • Perspective and Parallel view projections
  • Game world must have constraints and limits
  • Constants can be used to specify fixed quantities
  • Designing and developing games can be a lot of fun!
  • Skill Outcomes

  • Ability to code using the language of game developers
  • Ability to design and build a 2D or 3D game
  • Ability to draw 2D and 3D graphics using OpenGL
  • Ability to read input from a game pad / controller
  • Ability to create a working game options menu
  • Ability to move, position and animate 2D and 3D objects
  • Ability to keep a game in sync with time
  • Ability to create a classic ping pong game
  • Ability to create a space ship that can shoot down targets
  • Ability to manage multiple on screen objects
  • Ability to design build and play a complex 2D game
  • Ability to load, draw and animate 3D objects
  • Ability to create a 3D tank game
  • Introduction

    Game Programming 101 introduces the fundamentals of game programming using the real world game programming language, C with the real world graphics library, OpenGL.

    Game Programming 101 introduces game programming by delivering a Video Tutorial for each topic along with a practical example which may be demonstrated by the student.

    The 3D Game Builder is a tool for fast, intuitive game creation and becaue it looks after the technical stuff for you it allows us to instantly focus on the important learning topics.

    We will introduce drawing, main game loop, game timing, controller input and start to develop playable games which can use more than one game controller for multiple players. The first complete playable is a one or two player ping pong game. We also introduce simple maths to move objects, simulate gravity and detect collisions.

    For theory content that is demonstrated in this Game Programming 101 course please refer back to 3D Anatomy 101.

    Students that learn these fundamentals gain a clear and simple understanding of what drives their graphics, delivering a solid footing for careers in 3D, multimedia, animation and software development.

    Preparation

  • Learning and outcomes are activity based using our 3D Game Builder software

  • 3D Game Builder requires a game controller to be plugged into your PC

  • We use Visual Studio Express 2012 on Windows as the development platform

  • We have a complete set of project files for Visual Studio Express 2012

  • Downloads



    3D Game Builder


    Controller


    Visual Studio Express
    for Desktop


    Project Files
    for Visual Studio

    Proposed Lesson Plan

    Session 1 - Drawing

    To get started we show you how to create a simple hello world program using the 3D Game Builder SDK. SDK is a developer acronym for "Software Development Kit".

    Next we demonstrate how to draw geometric primitives using OpenGL.

    OpenGL is an industry standard graphics library for drawing 2D and 3D graphics. It is used to develop a wide range of software including 3D modelling and animation tools such as 3D Studio Max and Maya. It supports a wide range of hardware and operating systems from mobile phones to super computers.

    For more information on OpenGL visit www.opengl.org

    We use the language of game developers, C and C++, to develop our projects. This language can be challenging but it ensures you are using the same technology that the "real world" developers use. Therefore you are encouraged to learn more about C and C++ independently of this course.



    Hello World


    A Triangle


    Quad and Strip


    Triangle Fan

    Session 2 - Game Control Basics

    The 3D Game Builder SDK has convenient functions to read a game pad / controller. You use game pad / controller input to drive your entire game. We will ask you to create and control a simple menu and perform an action when you select an option.

    Managing multiple objects is essential to games so we get you to move a single "ball" shape around the screen. Then we extend that to manage many objects of the same type. Arrays are often used to store sets of objects of the same type.



    Controller Input


    Simple Menu


    Move a Ball


    More Balls

    Session 3 - A Basic Game

    In this session you start off by coding a ball to move around the screen, bouncing off each side. We then add a bat or paddle to one side and attempt to hit the ball back by controlling the paddle using the game pad / controller.

    We then add the other paddle and contol it automatically using software creating a one player ping pong game. We then ask you to create a fully automatic ping pong game with two computer controlled paddles.



    Bounce a Ball


    Game Timing


    Bat and Ball


    Ping Pong

    Session 4 - Rotating Objects

    If we rotate a triangle we see distortion in the shape as it turns. This is because the screen is drawn using a default view matrix. This makes the screen 2 wide and 2 high. The center of the screen = (0,0), the bottom left = (-1,-1) and the top right = (1,1).

    The triangle would look correct if our screen was square but it is not, it is rectangular. So to make it look correct we need to stretch the view matrix to be the same as the screen ratio. The screen ratio is the width divided by the height which is approximately 1.7 to 1.

    We can then create objects and rotate them without distortion. The next task is to create a space ship and make it fly in zero gravity and blow flames as we press the thrust button on the game pad / controller.

    We can move the ship at an angle by converting the angles to x,y values using sine and cosine math functions. Then we add gravity and test if it touches the ground (the bottom of the screen) and recover from a crash by standing the ship back up.



    Rotate a Triangle


    Fix Screen Ratio


    A Space Ship


    Simulate Gravity

    Session 5 - Shooting Targets

    Once we get familiar with moving a space ship on screen the next goal is to be able to shoot. We also need a method to recycle the shots so we do not create too many on screen at once and can eventually make the shot "die" if it fails to hit a target.

    Then we can add a static target and use a distance calculation to detect a "hit". If we hit the target we can "kill" the shot.

    The next step is to make the target move around on screen and then to be able to add and move around multiple targets on screen. We can use the same data for a shot and for target since they both share the same attributes and similar behaviour.



    Fire a Shot


    Add a Target


    Moving Target


    Multiple Targets

    Session 6 - Introduction to 3D

    The best way to get started with 3D is to use a cube object that we can rotate, pan and zoom on screen. We start with a parallel view projection first and then do the same thing using a perspective projection.

    We then open a more complex 3D model, a tank. Using the controller we can rotate the tank and its turret and can change the pitch of the gun barrel. We then add the tank to a ground drawn as a grid and add driving code to move the tank around the grid and also add the ability to fire a shot. Here, we use the same methods and techniques that we used to move and shoot with the space ship but are doing it within a 3D environment.

    You are challenged to extent the tank game by adding a second tank to the environment that is computer controlled. The shooting can be simple 2D or you could try to have the shot fire up and fall down to the ground depending on the pitch of the gun barrel.



    Parallel Cube


    Perspective Cube


    Control a Tank


    Drive a Tank

    Project

    Your challenge in this course is to design and develop your own game which can be similar to one of the classic "old school" shooting games. These early arcade video games include Space Invaders, Galaga, Asteroids and Space Wars.



    Space Invaders


    Galaga


    Asteroids


    Space Wars

    Support and Resources

    Contact us for personal support and assistance. We can help you install and establish our content "off-line" if necessary and have other learning tools and downloads which will help you deliver clean and efficient learning experiences.



    Contact Us