You are on page 1of 23

Video Games

VGD 2012-2013 Francis Joseph Seria

Goals
To understand the fundamental modules running in a game To understand the fundamental structure of all video games

Objectives
Identify and implement the fundamental structure of all video games in C++ Identify and implement the different modules in a video game

Core Values
Creativity
Free your mind

Curiosity
Your thirst for knowledge can never be quenched

Patience
Everything will turn out just right

As a Software
Video Games are fundamentally, software. Development of Video Games follow Software Engineering Practices and Methods. Unlike Business applications, a Video Game should continue with or without User Input. A major difference between Video Games and other software is that development teams include more than just programmers. They include artists, level designers, writers, etc. similar to movie production.

Video Games
Video Games always require a computer to receive player input, perform logic and return feedback to the player. Thus, card games and board games are not considered Video Games (even if they have Video Game versions).

Modules & Managers


Elements of a Video Game

Sample Modules

Sample Modules
A Video Game is comprised of different systems working together Each system is further divided into subsystems. For example:
Game Logic may consist of Physics and AI Graphics may include 2D and 3D Resources may handle images, meshes, audio sources, etc.

Each module may have a Manager that would handle all the subsystems and their interactions between other systems Most of the modules correspond to specific hardware types

Specialized Modules
There are devices which have specialized hardware for specific modules. For example:
Physics Modules (Physics Processing Units) Post Rendering Effects (Digital Signal Processor) Network Module Logging (Debugging)

Game Manager
The Game Manager is the core of a Video Game. Ideally, it is the entry and exit point of the program. The game manager initializes the other modules in the game. All objects in the scene that are either visible, has logic or both is managed by the Game Manager. These objects are commonly called Game Objects.
Game Objects are anything that is visible or has logic

The Game Manager handles the Game Loop

Time Manager
The Time Manager (or Timer) keeps track of the amount of time between iterations of the game loop Usually measured in milliseconds Other information that the Timer may keep track of:
Time elapsed since the Video Game started Time elapsed between video output (to determine or control frames per second)

Input Manager
The Input Manager (or simply Input) records the states of all available input devices to be used Input devices may differ per platform as listed:
For Desktop/Laptops; keyboard, joystick, mouse, webcam, microphone, etc. For Consoles/Handhelds; game pad buttons, joystick, IR, device orientation or motion, multi-touchscreen, camera, microphone, etc.

Other information the Input may record:


Duration of an input state (ex: charging of a weapon) Events or Change of state of an input (ex: on press, on release) Order of consecutive events (ex: combo, double click)

Output Manager
The Output Manager (or simply Output) handles feedback to the player Output is usually split into Audio and Video subsystems The Audio subsystem control the playing of music and sound effects The Video subsystem manages the visual feedback to the player, which may be in 2D, 3D or both

The Game Loop


Fundamental Structure for all Video Games

The Game Loop

The Game Loop


As mentioned before, Video Games should continue processing whether the user has entered any input or not Thus, we cannot use blocking input functions such as scanf() or cin to receive input. Instead, we save the states of all input devices to be used later on Then, we update the logic of the game and return an output before we repeat the cycle Each cycle in the game loop is called a frame, similar to the frames of a movie. After all, a video game is an interactive movie J

The Game Loop


bool isPlaying = true; if (!Init()) return -1; // Enter the game loop while (isPlaying) { Input(); Update(); Output(); } CleanUp();

Init() and CleanUp()


Init() is used for initializing the video game, initializing the modules and loading resources CleanUp() is used for releasing resources and shutting down the other modules Note:
The constructor and destructor may be used instead of Init() and CleanUp() These 2 functions are not part of the game loop

Input()
Input() calls the Input Manager to recheck all the states from the input devices

Update()
Update() contains the logic of the Video Game Objects react to player input or collisions Collision Tests, Physics and AI are also executed in the Update May not exactly be in the order as shown

Output()
Output() gives the player feedback Output devices differ per platform but they generally involve both Video and Audio Rather than displaying directly to the screen, we put the output in a buffer

Exiting the Game Loop


The Game Loop, and eventually the game itself, exits when the condition (isPlaying) becomes false

You might also like