Game Engine Notes
Game Engine Notes
Introduction:
● The software that drives these now-ubiquitous
three-dimensional worlds—Game Engines such as Unity,
Quake and Doom engines,Unreal Engine and Valve’s Source
engine—have become fully featured reusable software
development kits that can be licensed and used to build
almost any game imaginable.
● Virtually all game engines contain a familiar set of core
components, including the rendering engine, the collision and
physics engine, the animation system, the audio system, the
game world object model, the artificial intelligence system,
and so on.
Level of Detail:
● Level-of-detail (LOD) techniques are used to ensure that
distant objects are rendered with a minimum number of
triangles, while using high resolution triangle meshes for
geometry that is close to the camera.
● This technique is widely used in Fast paced games or heavy
games in order to give better experience and smoothness to
the game.
Occlusion Culling:
● Occlusion culling is a process which prevents Unity from
performing rendering calculations for GameObjects that are
completely hidden from view (occluded) by other GameObjects.
7. Other Genres:
● Each game genre has its own particular
technological requirements. This explains why game
engines have traditionally differed quite a bit from
genre to genre.
● With the advent of more and more powerful
hardware differences between genres that arose
because of optimization concerns are beginning to
evaporate. So it is becoming increasingly possible
to reuse the same engine technology across
disparate genres, and even across disparate
hardware platforms.
1. Target Hardware:
● This represents the computer system or console on
which the game will run. These platforms include
Microsoft-Windows, Linux based PC’s, Apple’s
iPhone and Macintosh, Xbox one and Xbox 360,
Playstation etc.
2. Device Drivers:
● Device drivers are low-level software components
provided by the operating system or hardware
vendor.
● Drivers manage hardware resources and shield the
operating system and upper engine layers from the
details of communicating with the myriad variants
of hardware devices available.
3. Operating System:
● It orchestrates the execution of multiple programs
on a single computer, one of which is your game.
● Windows employs a time-sliced approach to
sharing the hardware with multiple running
programs, known as preemptive multitasking.
● PC game can never assume it has full control of the
hardware—it must “play nice” with other programs in
the system.
● On a console, the operating system is often just a
thin library layer that is compiled directly into your
game executable. The game typically “owns” the
entire machine.
6. Core Systems:
● Assertions: are lines of error-checking code that
are inserted to catch logical mistakes and
violations of the programmer’s original
assumptions.
● Memory management: Virtually every game engine
implements its own custom memory allocation
system(s) to ensure high-speed allocations and
deallocations and to limit the negative effects of
memory fragmentation.
● Math library: provide facilities for vector and matrix
math, quaternion rotations, trigonometry,
geometric operations with lines, rays, spheres,
frusta, etc., spline manipulation, numerical
integration, solving systems of equations, and
whatever other facilities the game programmers
require
● Custom data structures and Algorithms: are often
hand-coded to minimize or eliminate dynamic
memory allocation and to ensure optimal runtime
performance on the target platform.
7. Resource Manager:
■ The resource manager provides a unified interface
(or suite of interfaces) for accessing any and all
types of game assets and other engine input data.
8. Rendering Engine:
The rendering engine is one of the largest and most
complex components of a game engine. Renderers
can be architected in many different ways.
➔ Low Level Renderer:
● It encompassses all of the raw rendering
facilities of the engine. The design is focused
on rendering a collection of geometric
primitives as quickly and richly as possible,
without much regard for which portions a
scene may be visible.
● Graphics Device interface: Graphics SDK’s
such as DirectX and OpenGL, require a
reasonable amount of code to be writt en just
to enumerate the available graphics devices,
initialize them, set up render surfaces
(back-buffer, stencil buffer etc.), and so on.
● Other Renderer Components: The other
components in the low-level renderer
cooperate in order to collect submissions of
geometric primitives (sometimes called render
packet s), such as meshes, line lists, point lists,
particles , terrain patches, text strings, and
whatever else you want to draw, and render
them as quickly as possible.
➔ Scene Graph/Culling Optimizations :
● The low-level renderer draws all of the geometry
submitted to it, without much regard for whether or
not that geometry is actually visible (other than
back-face culling and clipping triangles to the
camera frustum). A higher-level component is
usually needed in order to limit the number of
primitives submitted for rendering, based on some
form of visibility determination.
➔ Visual Effects :
Modern game engines support a wide range of visual
effects such as:
● Particle systems (for smoke, fire, water splashes, etc.).
● Decal systems (for bullet holes, foot prints, etc.).
● Light mapping and environment mapping.
● Dynamic shadows.
● Full-screen post effects , applied after the 3D scene has been
rendered to an off screen buffer.
Some Examples of full-screen Post effects Include:
● High dynamic range (HDR) lighting and bloom.
● Full-screen anti-aliasing (FSAA).
● Color correction and color-shift effects, including bleach
bypass , saturation and desaturation effects, etc.
It is common for a game engine to have an effects system
component that manages the specialised rendering needs of
particles, decals and other visual effects.
➔ Front end
Games employ some kind of 2D graphics overlaid on the 3D
scene for various purposes which include-
● The game’s heads-up display (HUD).
● In-game menus, a console, and/or other development
tools, which may or may not be shipped with the fi nal
product.
● Possibly an in-game graphical user interface (GUI),
allowing the player to manipulate his or her character’s
inventory, configure units for battle, or perform other
complex in-game tasks.
11. Animation:
● Any game that has organic or semi-organic
characters (humans, animals, cartoon
● characters, or even robots) needs an
animation system.
There are five basic types of animation used in games-
➢ Sprite/texture animation
➢ Rigid body hierarchy animation,
➢ Skeletal animation
➢ Vertex animation
➢ Morph targets.
13. Audio:
● It is just as important as graphics in any
game.
● No great game is completed without a
stunning audio engine.
● Audio engines vary greatly in sophistication.
➢ Quake ’s and Unreal ’s audio engines are
pretty basic, and game teams usually
augment them with custom functionality
or replace them with an in-house
solution.
➢ For DirectX platforms (PC and Xbox 360),
Microsoft provides an excellent audio
tool suite called XACT .
➢ Electronic Arts has developed an
advanced, high-powered audio engine
internally called SoundR!OT.
➢ In conjunction with first-party studios
like Naughty Dog, Sony Computer
Entertainment America (SCEA) provides
a powerful 3D audio engine called
Scream.
14. Online Multiplayer/ Networking:
● Many games permit multiple human players to
play within a single virtual world. There are
different types such as:
➢ Single-Screen Multiplayer
➢ Split Screen Multiplayer
➢ Networked Multiplayer
➢ Massively Multiplayer online games (MMOG)
● Multiplayer games are quite similar in many
ways to their single-player counterparts.
However, support for multiple players can
have a profound impact on the design of
certain game engine components.
● Many game engines treat single-player mode
as a special case of a multiplayer game.
● The Quake engine is well known for its
client-on-top-of-server mode, in which a single
executable, running on a single PC, acts both
as the client and the server in single-player
campaigns.
Event System:
● An event driven architecture is a common approach to
inter-object communication.
● In an event-driven system, the sender creates a little data
structure called an event or message, containing the
message’s type and any argument data that are to be
sent. The event is passed to the receiver object by calling
its event handler function.
Scripting System:
● Many game engines employ a scripting language in order to
make development of game-specific gameplay rules and
content easier and more rapid.
● Without a scripting language, you must recompile and relink
your game executable every time a change is made to the
logic or data structures used in the engine.
● Some engines allow scripts to be reloaded while the game
continues to run. Other engines require the game to be shut
down prior to script recompilation.
b. 3D Models (Meshes):
● 3D models (also referred to as meshes) are superior to
brush geometry. A mesh is a complex shape composed
of triangles and vertices.
● On modern graphics hardware all shapes must
eventually be translated into Triangles prior to rendering.
A mesh typically has one or more material applied to it in
order to define Visual surface properties.
● Meshes are typically created in a 3D modelling package
such as 3DS Max, Maya etc.
● Exporters must be written to extract the data from the
digital content creation tool and store it on disk in a
form that is digestible by the engine.
● Game teams often create custom file formats and custom
exporters to go with them.
Audio Data:
● Audio clips are usually exported from Sound Forge or some
other audio production tool in a variety of formats and at a
number of different data sampling rates.
● They may be in mono, stereo, 5.1, 7.1 or other multi-channel
configurations. Wave files are common but other file formats
such as PlayStation ADPCM are also commonplace.
Vector operations:
Most of the mathematical operations that we perform on
scalars can be applied for vectors as well.
Matrices:
● A matrix is a rectangular array of m x n scalars.
Mattresses are a convenient way of representing linear
transformation such as translation rotation and scale.
● A matrix M is usually written as a grid of scalars Enclosed
in square brackets where the subscripts r and c represent
the row and column indices of the entry respectively.
● When all of the row and column vectors of a 3 × 3 matrix
are of unit magnitude, we call it a special orthogonal
matrix. This is also known as an isotropic matrix, or an
orthonormal matrix.
● Under certain constraints, a 4 × 4 matrix can represent
arbitrary 3D transformations ,including translations ,
rotations , and changes in scale . These are called
transformation matrices , and they are the kinds of
matrices that will be most useful to us as game engineers.
The transformations represented by a matrix are applied
to a point or vector via matrix multiplication.
Matrix Multiplication:
● The product P of two matrices A and B is writt en P = AB. If
A and B are transformation matrices, then the product P
is another transformation matrix that performs both of
the original transformations. For example, if A is a scale
matrix and B is a rotation, the matrix P would both scale
and rotate the points or vectors to which it is applied.
Matrix Inversion:
● The inverse of a matrix A is
another matrix (denoted A–1)
that undoes the effects of matrix A
● When a matrix is multiplied by its own inverse, the result is
always the identity matrix.
Transposition:
● The transpose of a matrix M, is obtained by reflecting the
entries of the original matrix across its diagonal. In other
words, the rows of the original matrix become the
columns of the transposed matrix, and vice-versa.
● The inverse of an orthonormal (pure rotation) matrix is
exactly equal to its transpose.
● Transposition can also be important when moving
● data from one math library to another, because some
libraries use column vectors while others expect row
vectors. The matrices used by a row-vector based
● library will be transposed relative to those used by a
library that employs the column vector convention.
Coordinate Spaces:
● Applying transformation to a rigid object is like applying
that same transformation to every point within the object.
a point (position vector) is always expressed relative to a
set of coordinate axes.
● A set of coordinate axes represents a frame of reference,
so we sometimes refer to a set of axes as a coordinate
frame (or just a frame). People in the game industry also
use the term coordinate space (or simply space) to refer
to a set of coordinate axes.
➢ Model Space: The positions of the triangles’ vertices
are specified relative to a Cartesian coordinate
system which we call model space. The model space
origin is usually at a central location within the
object.
➢ World Space: It is a fixed coordinate space, in which
the positions, orientations, and scales of all objects
in the game world are expressed. This coordinate
space ties all the individual objects together onto a
cohesive virtual world. The location of the
world-space origin is arbitrary.
➢ View Space: it is a coordinate frame fixed into the
camera. The view space origin is place at the focal
point of the camera.
Change of Basis:
● It is often quite useful to convert an object’s position,
orientation, and scale from one coordinate system into
another. We call this operation a change of basis.
● Coordinate Space Hierarchies:
Coordinate frames are relative. That is, if you want to
quantify the position, orientation, and scale of a set of
axes in three-dimensional space, you must specify these
quantities relative to some other set of axes . This implies
that coordinate spaces from a hierarchy every coordinate
space is a child of some other coordinate space, and the
other space acts as its parent. World space has no
parent; it is at the root of the coordinate-space tree, and
all other coordinate systems are ultimately specified
relative to it, either as direct children or more-distant
relatives.
Quaternions:
● A matrix is not always an ideal representation of a
rotation,
Therefore we use quaternions for a number of reasons:
➢ We need nine floating-point values to represent a
rotation, which seems excessive considering that we only
have three degrees of freedom—pitch, yaw, and roll.
➢ To find a rotational representation that is less expensive.
➢ To find lots of intermediate rotations be tween A and B
over the course of the animation.
● There is a rotational representation that overcomes these
three problems. It is a mathematical object known as a
quaternion. A quaternion looks a lot like a
four-dimensional vector, but it behaves quite differently.
We usually write quaternions using non-italic,
non-boldface type, like this: q = [ qx qy qz qw ].
3x3 Matrices:
● A 3x3 matrix is a convenient and effective rotational
representation. It does not suffer from gimbal lock , and it
can represent arbitrary rotations uniquely.
● It can be applied to points and vectors in a
straightforward manner via matrix multiplication.
● Most CPUs and all GPUs now have built-in support for
hardware-accelerated dot products and matrix
multiplication. Rotations can also be reversed by finding
an inverse matrix, which for a pure rotation matrix is the
same thing as finding the transpose—a trivial operation.
And 4 × 4 matrices offer away to represent arbitrary affine
transformations—rotations, translations, and scaling—in
a totally consistent way.
● Rotation matrices are not easily interpolated and takes
up a lot of storage.
Axis+Angle:
● Rotation can be represented as a unit vector defining the
axis of rotation plus a scalar for the angle of rotation
where ‘a’ is the axis of rotation and 𝚹 the angle in radians.
● The benefits of the axis+angle representation are that it is
reasonably intuitive and also compact.
● Rotations cannot be easily interpolated. rotations in this
format cannot be applied to points and vectors in a
straightforward way—one needs to convert the axis+angle
representation into a matrix or quaternion first.
SQT Transformations:
● When a quaternion is combined with a translation vector
and a scale factor. We sometimes call this an SQT
transform, because it contains a scale factor, a
quaternion for rotation, and a translation vector.
Dual Quaternions:
● Complete transformations involving rotation, translation,
and scale can be represented using a mathematical
object known as a dual quaternion. A dual quaternion is
like an ordinary quaternion, except that its four
components are dual numbers instead of regular
real-valued numbers.
Principle of Vectors:
Vector is a line with Magnitude (Length) and Direction. It is
used to represent measurements such as displacement,
velocity and acceleration. In 2D, a vector has 2 coordinates- x
and y and in 3D, a vector has 3 coordinates- x,y and z . (In pure
mathematics, a vector is a set of changing coordinate
instructions.)
The length of a vector, v, called its magnitude and written.
Cameras:
The camera in a game defines the visible area on the screen. In
addition to defining the height and width of the view, the
camera also sets the depth of what can be seen. The entire
space visible by a camera is called the view volume. If an object
is not inside the view volume, it is not drawn on the screen.The
the shape of the view volume can be set to orthographic or
perspective. Both views are constructed from an eye position
(representing the viewers’ location), a near clipping plane, the
screen, and a far clipping plane.
Orthographic Camera:
An orthographic camera projects all points of 3D objects
between the clipping planes in parallel onto a screen planeThe
screen plane is the view the player ends up seeing. The viewing
volume of an orthographic camera is the shape of a
rectangular prism.
Perspective Camera:
A perspective camera projects all points of 3D objects between
the clipping planes back to the eye. The near clipping plane
becomes the screen. The viewing volume of a perspective
camera is called the frustum as it takes on the volume of a
pyramid with the top cut off. The the eye is located at the apex
of the pyramid.
● The camera in a game is a critical component as it
presents the action to the player. It is literally the lens
through which the game world is perceived.
● Cameras are also important for optimizing a game
performance. all objects inside the view volume get drawn
to the screen. The more objects to be drawn, the slower
the frames per second. Even objects behind other objects
and not noticeably visible will be considered by the game
engine as something to be drawn. So even though an
object does not appear on the screen, if it is inside the
camera’s view volume it will be processed.
● Whether the camera is looking at an orthographic or a
perspective view, the coordinate system within the game
environment remains the same.
Quaternions:
Quaternions are mathematical constructs that allow for
rotations around the three axes to be calculated all at once in
contrast to Euler angles that are calculated one after the
other. A quaternion has an x, y, and z component as well as a
rotation value.
In games using Euler rotations can cause erratic orientations
of objects.Quaternions are used throughout modern game
engines including Unity, as they do not suffer from gimbal
lock.
nity uses quaternions for storing orientations. The most used
quaternion functions are-
LookRotation():
LookRotation() given a vector will calculate the equivalent
quaternion to turn an object to look along the original vector.
Angle():
The Angle() function calculates the angle between two
rotations. It might be used to determine if an enemy is directly
facing toward or away from the player.
Slerp():
Slerp() takes a starting rotation and an ending rotation and
cuts it up into small arcs. It is extremely effective in making
rotating objects change from one direction to another in a
smooth motion
Anticipation:
Presenting short actions or hints to a viewer of what is about
to
Happen. A simple implementation of this is seen in racing
games. At the beginning of a race, a traffic light or countdown
will display, giving the player a heads up to when the race is
about to start. Another way to add anticipation is to have
explosive devices with countdown timers.
Follow-through and overlapping action:
This is the way in which momentum acts on a moving object
to cause extra motion even after the initial force has stopped.
For example in racing games, a common follow-through is
when one car clips another car and it goes spinning out of
control. In most games where you have to blow something up
there is bound to be a follow-through action that removes
obstacles from the player’s game progression.
Secondary actions:
These animations support the principle animation. They give
a scene with more realism. Secondary motion brings the game
environment to life. The simplest of movements can hint at a
dynamic realistic environment with a life of its own. For
example, a swaying tree or moving grass provides the illusion
of a light breeze while also suggesting to the player that these
are living things.
Staging:
Presenting an idea such that no mistake can be made as to
what is happening.
Timing:
This refers to the speed of actions. It is essential for
establishing mood and realism.
Exaggeration:
Perfect imitations of the real world in animation can appear
dull and static. Often it is necessary to make things bigger,
faster, and brighter to present them in an acceptable manner
to a viewer. Over Exaggeration is also used in physical features
of characters for the effects of physics.
Solid drawing:
This is the term given to an animator’s ability to consider and
draw a character with respect to anatomy, weight, balance,
and shading in a 3D context. A character must have a
presence in the environment, and being able to establish
volume and weight in an animation is crucial to believing the
character is actually in and part of the environment.
Appeal:
This relates to an animator’s ability to bring a character to life.
It must be able to appeal to an audience through physical
form, personality, and actions.
Primary Mechanics:
● Primary mechanics can be understood as core mechanics
that can be directly applied to solving challenges that
lead to the desired end state. Primary mechanics are
readily available, explained in the early stages of the
game, and consistent throughout the game experience.
1. Searching:
● Searching is a basic human cognitive process that
involves perception and scanning of an environment.
● In computer games, this ability is leveraged to make the
player look for a specific piece of information, item,
location, or character in an environment.
● The objective of the player’s search may be to find an item
needed to proceed in the game, for example, a key to
open a door, or to navigate a maze to get from one place
to another.
2. Matching:
● Matching is an activity that is part of the searching
process.
● In a game, matching is used to get players to put one or
more things together because they are smaller pieces of
a whole, or are the same color or shape, or have other
similar characteristics. This common action may find
players putting together parts of a machine to make it
work as a whole or placing the same colored items next to
each other on a grid.
3. Sorting:
● In a game, matching is used to get players to put one or
more things together because they are smaller pieces of
a whole, or are the same color or shape, or have other
similar characteristics. This common action may find
players putting together parts of a machine to make it
work as a whole or placing the same colored items next to
each other on a grid.
4. Chancing:
● Chance devices such as die and the drawing of straws for
purposes of sorting, selecting, and division
● Chance in games is used to determine the probability of
future outcomes. This is one of the oldest actions used in
games involving the use of dice, rolling or coin tossing to
determine an outcome based on chance. Without some
element of probability in which players knew what the
outcome of their actions would be before they did them,
there would not be any need to take a risk.
5. Mixing:
● Mixing actions involves the combining of objects or
actions to produce an outcome unachievable otherwise.
● In computer games, actions can be combined to allow
characters to perform tasks they could not do with single
actions, for example, jumping while running to leap across
a crevasse in the game world or combining multiple
keystrokes to perform special moves
6. Timing:
● The use of time in a computer game can be applied to as
a game mechanic. It could involve completing a task
within an allotted time, timing an action, or waiting for
some event to occur. This mechanism is used to instigate
urgency in situations such as racing, whether it is against
the clock or an opponent or to generate anticipation
when waiting for something to occur or forcing patience
upon a player who has to wait for the game environment
to change.
7. Progressing:
● Games employ a progression scheme in which the player
begins as a noob and progresses to the level of expert at
the end. Along this journey, progression schemes are put
in place that give players a feeling of achievement for
their effort.
8. Capturing:
● To capture is to take something that belongs to someone
else through force or your own effort.
● Some games embed this mechanic as the primary
objective of the game. For example, Civilization requires
players to take over other cities and countries. The Dutch
East India Company challenges players to take cities
along the spice route in order to be able to build a more
profitable trading company between European and East
Asian cities.
● Capturing can also be used in a game in not such a literal
sense. For example, it could involve knocking out another
game character in order to steal his weapon or stealing a
car to make a quick getaway.
9. Conquering:
● In a similar vein to capturing is the action of conquering.
Conquering is about outdoing or annihilating the
competition.
● Outdoing an opponent is a classic game play goal. For
example, in chess, the aim is to get your opponent into
checkmate while taking pieces along theway or make
them surrender
10.Avoidance:
● Numerous games require the player to avoid items and
situations that are harmful to their character.
● Instead of telling players what they can do, avoidance is
all about showing them what they cannot. The inability to
avoid whatever it is they should be avoiding penalizes
players through reduced points or health given the
situation.
● Avoidance places constraints on the actions of players
such that they must keep in mind what they cannot do
while trying to progress through the game environment.
11. Collecting:
● Collecting is another natural human behavior
● Some items can be collected and placed in an inventory
to be used at a later time. When used, these might
disappear or go back into the inventory. The collecting
mechanic is often used for searching. Other collection
activities can happen almost by mistake.
3. Racing:
● Racing involves one or more players attempting to get
from one location to another in order to beat the clock or
beat one another. Racing is a common sport found
involving unaided human participants (in many Olympic
events), motor vehicles (such as formula 1 or drag racing),
and animals (including horses, dogs etc).
● Many computer games include racing in a variety of
forms such as Project Gotham, Grand Theft Auto V etc.
● Racing need not involve people or vehicles moving
around a track. Performing a task within a certain time is
racing against the clock.
5. Searching:
● Searching is a common human activity Naturally, the
searching mechanism goes hand in hand with matching.
● The ways in which searching is implemented as a game
mechanic are as varied as game genres.
● Searching can be performed by moving the mouse
around a scene to find and pick up objects. It can also
involve moving the main character around a game level.
● Of all the forms and applications of AI, games use a very small
subset, the majority of which is to develop the behavior of
nonplayer characters (NPCs). AI is used primarily for decision
making in NPCs that allow them to find their way around maps
and interact intelligently with other players
Line Of Sight
● The simplest method for programming an NPC to follow the player
and thus provide it with modest believable behavior is using the
line of sight. The NPC sees the player, turns to face the player, and
travels in a straight line forward until it reaches the player. This
straightforward approach can make the player feel under attack
and that the NPC is a threat and has bad intentions.
● The NPC detects the player within its field of vision using the
vector between its position and the players. It is calculated as:
Graph Theory
● Almost all AI techniques used in games rely on the programmers
having an understanding of graphs
Waypoints
● It is a means of marking a route on a map that NPC’s can follow. A
waypoint is simply a remembered location on a map. Waypoints
are placed in a circuit over the map’s surface and are connected
by straight line paths. Paths and waypoints are connected in such
a way that an NPC moving along the paths is assured not to
collide with any fixed obstacles. Waypoints and their connecting
paths create a graph. Moving from one waypoint to another
waypoint along a path requires an algorithm to search through
and find all the nodes and how they are connected to each other.
● The BFS takes the given starting node and examines all adjacent
nodes. Nodes that are adjacent to a starting node are the ones
that are connected directly to the starting node by an edge. from
each of the adjacent nodes, nodes adjacent to these are
examined. This process continues until the end node is found or
the search for adjacent nodes has been exhausted.
Flocking
● Applying flocking principles to NPCs in a game can add extra
realism to the environment as secondary animations.
Decision Trees
● Decision trees are hierarchical graphs that structure complex
Boolean functions and use them to reason about situations. A
decision tree is constructed from a set of properties that describe
the situation being reasoned about. Each node in the tree
represents a single Boolean decision along a path of decision that
leads to the terminal or leaf nodes of the tree.
Fuzzy Logic
● Fuzzy logic provides a way to make a decision based on vague,
ambiguous, inaccurate, and incomplete information. Fuzzy logic
works by applying the theory of sets to describe the range of
values that exist in vague terminologies.
Player Mechanics
● Players require feedback from the game in order to determine
their status and progress. This could be in the form of a heads-up
display (HUD) that informs them of their health, money, enemy
location, and much more.
● A visual representation of the player’s status is a common way to
relay information from the game to the player. There are all sorts
of numeric values stored in the game code for keeping track of
the player’s status
● The best-designed HUDs are ones that show the most amount of
information without cluttering the screen or distracting the player
from the game itself.
User Profiling
● We need to know for whom you are designing a HUD , before
designing one. We should consider the player’s existing skills and
experience, goals, and needs.
Metaphor
● Metaphors are the perfect example of how we love to liken one
thing to another and how we make sense of new imagery from our
experiences. The perfect example of this with respect to game
mechanics and interfaces is the play button first appearing on
original analogue sound-playing devices.
● Two popular metaphors that have arisen purely within the game
domain are the spacebar for jump and holding down the shift key
to run. Although they are not visual metaphors, they are still part
of the user interface and clearly illustrate how metaphors can be
leveraged. Metaphors also extend to any menu systems in the
game.
● In games that have toolbars that are commonly used, they always
appear on the screen. Sometimes not all features can be exposed
at the top toolbar level as there may be too many, and the
interface would be over complicated. In this case, the toolbar is
given a hierarchical structure in which if one option is clicked, it
opens up a second lot of options.
Coherence
● Elements of your interface design should fit together both
functionally and visually. In addition, the game interface should
match the functionality of the platform for which it has been built.
Shortcuts
● Learning keyboard shortcuts is synonymous with learning what
the buttons on a game controller control. These shortcuts allow
players to get to regularly used functionality or to information
embedded in the menu system or toolbar and usually require
some clicking action to achieve. Players will use shortcuts to
perform game actions more quickly.
Focus
● The HUD displays the player status and other information but
should also draw the eye to any critical changes made to the
interface. Color changes and animations work best for attracting
the player’s attention
Help
● It goes without saying that a game should present the user with
help on how to play. It needs an interface should be able to
provide the user: goal oriented, descriptive, procedural,
interpretive, and navigational.
Inventories
● Inventories are a game mechanic that span numerous game
genres. Basically they are a list of items that players have in their
possession. Inventories can be a fixed size, allowing only a finite
number of items or infinite items. This inventory size restriction
adds a new mechanic all of its own where players must prefer the
items they have.
● One example of a very complex inventory is the one that players
have in EVE Online. Players can have multitudes of ships, minerals,
ship parts, and blueprints in their possession. And these all are
not in the same location. Minerals and parts can be on ships and
ships can be docked on different planets. It is quite a feat of
logistics to manage the location of items and ships to facilitate
the most efficient game play.
Teleportation
● Teleportation is a player mechanic often used to move the player’s
character very quickly to different locations in a map. It can
happen explicitly via actual teleportation devices placed in a
game environment, which make it obvious that the player’s
location has changed or inexplicitly by which teleportation is the
developer’s trick for loading another game level or another part of
a map. Inexplicit teleportation can occur when very large game
environments need to be divided up into workable chunks the
computer’s processor can handle. If you play the original Halo,
you will experience this transition. When the player reaches the
physical boundary of a game mesh, a shimmer falls over the
screen and the next part of the map is loaded. The same type of
teleportation can occur when a character reaches the exterior
door of a building and the game needs to load the inside map of
the building so the player can enter it and continue playing.
Environmental Mechanics
Map Design Fundamentals
Map design for game levels is a sizable area of discussion and rules,
and opinions on the best approach differ between genre and game
developers.
● In a rather busy map, a large focal object that can be seen from
most places in the level will assist the player with orientation
● Terrain map, subtly guide the player along a path where the sides
are defined by steep inclines, vast drops, or endless water.
● Enemy and reward placement also push the player into moving in
a certain direction. Players of first person shooters know that they
are moving toward their goal as the number of enemies increases
Scaling
● Do not be afraid to resize an original asset. Look at the real world
and the proportions of objects within.
● Demonstrates the unnatural looking proportions of the barrels (a)
and how they are better matched to the size of the player’s
character (b). If there is a door in the scene, make sure it has
correct proportions with respect to the player’s character. The
same goes for stairs, furniture, trees, cars, and anything else in
the scene.
Detail
● The same observational prowess used for proportions should be
applied to map details. The details that make the real world seem
real.
Map Layout
● Physical map layout differs dramatically according to the
restrictions of perspective, narrative, and genre. Sometimes the
logical structure of the story and the game play paths from start
to end match with the analytical structure of the game
environment and sometimes they do not.
Open
● A truly open game map will have multiple starting positions and
ending positions with numerous unordered challenges in between.
From a narrative point of view, as you can start with any character
you like, end the game when you like, and take on whatever
challenges take your fancy along the way.
● The game environment of The Sims is also quite open in the way
by which players can decide on the look, personality, and goals of
their avatars and the layout
Linear
● Most games based around a story are linear; that is, they have a
start, a journey, and an end. Players typically accompany their
character, the hero, through a series of carefully crafted
challenges to the end. The start is always the same, the journey is
always the same, and the end is always the same. In terms of a
map, it means a game environment in which there is only one path
to travel to get from the starting position to the end. Along the
way there may be puzzles, barriers and enemies to battle, but the
path is always the same.
● Even more complexity is created when circuits are added off the
main path. These provide players with opportunities to bypass
parts of the main path. They can also disorient players and send
them back to the beginning.
● Any game that has a linear storyline similar to that in books and
movies will require a linear map to ensure that players play
through the story and live out the full life of their character. If the
physical map has sidetracks and circuits, players will require a
motivational story by which to choose to explore them.
Branching
● A level with branching has the one starting position and multiple
ending positions. Narratively speaking, this means a story that
starts in the same place but has multiple outcomes depending on
the player’s game choices. These are difficult narratives to write,
as a new story needs to be written for each branch. In addition,
extra branches require extra artwork with respect to map designs.
Flow
● Flow in level design refers to the way in which players move from
the beginning of the level to their goal. It is the level designer’s job
to make the environment flow as best he can to challenge players,
keep them moving toward their goal, and keep them engaged.
● Although in the end we all know that the designer is herding the
player down a certain path, this need not be revealed to the player
immediately. Providing players with numerous paths to take allows
them to make decisions in their game play about the way they
traverse the map.
Trapping
● Blocking the exit of a dead end after the player has entered is
another way to create tension and panic. You could use this
pathway through a map or at the goal location. It should be
obvious that if you do trap a player in part of the level, he is able
to get out.
Vantage
● Ensure that your map has multiple vantage points where the
player can hide or use as an attacking position. Some might be in
better locations than others and will provide players with choice
and variety in the way they choose to approach the game play.
Terrain
● Terrains are meshes that make up the ground in an outdoor
scene. They usually undulate in height and sport a variety of
surface textures to make them look like a real outdoor desert,
mountain, and even alien world scenes. The more detailed a
terrain, the more polygons from which it will be made as
additional vertices are required to give them a real-world smooth
appearance. Because large elaborate terrains require a lot of
processing, numerous tricks are employed to make the terrain
look more detailed.
● While there are many available tools for creating terrains, making
them look real can be quite a challenge. The best examples come
from nature.
Drawing a Terrain
As you will find in the next section, although a terrain can be computer
generated, the most detailed and realistic terrains are best created by
hand.
Procedural Terrain
● Procedural terrain is that generated by a computer algorithm.
Most of the methods are based on fractals. A program is written
that define the vertices of a mesh and recursively raises and
lowers the points to create altitude. One simple terrain producing
method is the midpoint displacement algorithm.
Procedural Cities
● Generating realistic cities with code is more challenging than
landscapes. While terrain can reuse trees, rocks, grass, and dirt
textures, reuse of the same building or random street structures
can look unrealistic. In the same way that fractals can be used for
generating terrain and layout, they too can be used to create
objects on the terrain such as trees and buildings.
Infinite Terrain
● Infinite terrain or endless terrain is a form of procedurally
generated landscapes. It uses a mathematical equation and the
player’s current position to create the landscape as the player
moves. Small parts of the map are created as needed based on
the player’s visible distance. Any map outside the visible range is
not generated, and therefore not a load on computer memory.
● To create undulation of a terrain, a mathematical formula is used
for determining the height based on the x and z positions on the
terrain for which there will always be a y value no matter the x and
z values.
● The beauty of using a formula is that the result of y for any x and
z values is always going to be the same, thus assuring us that if we
return to a previous location on the map that was destroyed after
we left but recreated on our return, the height remains the same.
Camera Tricks
● Cameras are the player’s eyes into the game environment. What
the camera sees is projected onto the computer screen. Before
each pixel is drawn, the game developer can add special
treatments to the properties and colors of the pixels by attaching
scripts to the camera. This allows for the creation of many
different visual effects.
Depth Of Field
● Depth of field is the term used to describe how an optical lens
focuses on the surrounding environment. It describes the distance
between the closest and the farthest objects in view that appear
in sharp focus.
Grayscale
● Grayscale reduces colored images down to variations of gray such
that it looks like a black and white photograph. The simplest
method for creating grayscale from color is the average method
that takes the red, green, and blue components of a pixel and
divides them by three. This new value is reassigned to the original
pixel. The lightness method sets a pixel value to the average of its
highest and lowest color components.
Motion Blur
● Motion blur is an effect used to make something look like it is
moving rapidly or to give the player a dreamy view of the
environment. The pixels appear to streak across the page in the
direction of the motion. In addition, objects can have ghosting
effects surrounding them. The effect is achieved by partially
leaving the previous frame on the screen while rendering the next
one. This effect is also useful in persuading players that their
character is disorientated as a result of being drugged or in a
dream state.
Sepia Tone
● Sepia tone is the brownish tinge seen on old photographs and
film. It is achieved using an algorithm similar to that used for
grayscale. The red, green, and blue values of a pixel are reset
based on the addition of percentages of their original color
components.
Twirl
● The twirl effect takes a portion of the screen pixels and wraps
them around a whirlpool-type motion. This effect is usually seen in
film footage or cut scenes when one scene is crossing into
another.
Bloom
● Bloom is the glow effect seen around light sources that extend
into the environment. It makes an image look overexposed and the
colors washed out. It is more prominent the stronger the light
source and the dustier the environment.
Flares
● Flares are bursts of reflected and refracted light. The most
commonly known flare is a lens flare, which causes a series of
translucent, rainbow, bright circles on an image from light passing
through a camera lens. It is often used in games to give the player
the illusion that they are looking into the sun when facing skyward
Color Correction
● It takes certain colors occurring in an image and changes them to
another color. For example, a hill covered in green grass could be
made to look like a hill of dead brown grass by replacing the color
green with brown.
Edge Detection
● An edge detection algorithm scans an image for areas where
pixels in close proximity contrast in color. Because the difference
between individual pixels would produce erratic effects, the
algorithm must determine if a pixel is on the edge of an area of
similar color by looking at its surrounding pixels. This creates a
picture that looks like a sketched outline The optimal approach to
edge detection is the Canny edge detection algorithm.
Crease
● Creasing is a non photorealistic effect that increases the visibility
of game world objects by drawing a line around the silhouette,
much like in comic book images. In a busy game environment with
many objects, such as buildings and trees, drawn from similar
colors and tones, objects can become difficult to distinguish. By
applying creasing at differing depths, the line can distinguish
between near and far objects.
Fish Eye
● The fish eye effect produces an image as seen in a spherical
mirror or through a wide-angle lens. The image produced is
hemispherical in nature.
Sun Shafts
● Sun shafts are produced by a bright light source being partially
occluded and viewed when passing through atmospheric
particles.
Vignette
● Vignetting is an effect used to focus the viewer’s attention on an
object in an image by darkening and/or blurring the peripheries.
In a game view, a vignette can focus the player’s attention on an
area of the game environment or be used to restrict the player’s
view.
Skies
● There are a number of ways to create skies for a 3D game
environment. The easiest way is to set the background color of the
camera to blue. Alternatively, if you want to include fog, setting
the fog color to the background color gives the illusion of a heavy
mist and provides for landscape optimization.
Skyboxes
● The most common method of creating a sky with cloud textures is
to use a skybox. This is essentially an inside-out cube placed over
the camera with seamless images of the sky rendered on it.
Because it only requires six planes and six textures, it is a
relatively cost-effective way to create a convincing-looking.
Sky Domes
● It is a dome mesh placed over the environment with a sky texture
stretched across the inside surface.
● Because the UVs of the sky dome are inline in arcs across the sky
mesh, it is simple to scroll textures across the mesh in the same
way the textures are scrolled across a plane. This makes it easy to
add cloud textures to the dome and move them across the sky.
Clouds
● The previous two sections examined skies with clouds. Clouds on
the skybox were fixed and did not change position or color. Clouds
on the sky dome moved across the sky and exhibited turbulence.
While the sky dome method includes layers of clouds, giving the
perception of depth, the player can never get above or in among
them. When you want to portray clouds in a 3D fashion such that
you can walk around or through them, then you need to explore
techniques for generating volumetric fog.
Weather
● The weather affects the look and feel of our environment
dramatically. The correct lighting, coloring, and special effects will
make them feel like they are there and add an extra dimension to
your scene.
Wind
● Wind is one of these elements. Although you cannot see it, it
moves environmental objects around. It looks especially good in a
3D world when acting on cloth, trees, and grass.
Precipitation
● Rain and snow add yet another dimension to the game
environment. Not Only do they look good, but they add
atmosphere and can be used to impair the vision of the player
strategically. Precipitation falls into a category of computer
graphics special effects called particle systems. They rightly
deserve a category of their own and as such will be dealt with in
the next section.
● It differs from the Kinect in that the Kinect only captures distances
from the device itself to whatever is in front of it and tracks for key
human features such as the hands, feet, and head.
● Besides the full body detection systems, simple mouse and finger
swiping gestures have been used in games. Matching the swiping
action to a specific gesture is an exercise in machine learning.
There are numerous methods for recognizing gestures including
Bayesian and neural networks, and complex artificial intelligence
techniques
3d Viewing
● Viewing virtual objects in three dimensions, otherwise known as
stereoscopy or stereoscopics, is a technology that has been
around since the beginning of the twentieth century.
Side-By-Side
● The earliest displays worked by showing a pair of 2D images in a
stereogram. By providing each eye with a different image taken
from a slightly different point of view, the brain can be fooled into
perceiving depth. This technique for stereoscopy is called
side-by-side.
Head-Mounted Displays
● The first commercially available HMDs were the Forte VFX-1 and
Sony Glasstron, which was used in the game MechWarrior 2
allowing players to see the game world through their own eyes
inside their craft’s cockpit.
Augmented Reality
● Although augmented reality (AR) technology has been available
since 1968, it has only been in the past five or so years that
applications have become increasingly popular. Technology from
the domain of three-dimensional gaming is particularly a key with
respect to AR as it allows efficient and seamless integration of
high-quality animated virtual objects with AR applications.
● In these games, players see their real world streamed via a camera
onto the screen and superimposed with virtual game characters.
The characters are positioned such that they appear to exist in
the real world. The player almost feels like they can reach out and
touch them.
● AR is a multidisciplinary field based on computer science with the
goal of providing a viewer with an environment containing both
real and virtual objects. With the use of mobile devices with
cameras, computer-generated images are projected on top of the
physical environment. To ensure correct positioning of virtual
objects in the real world, hardware and software are required to
determine accurately the viewer’s location and orientation
Memory Management
● As game developers, we are always trying to make our code run
more quickly. The performance of any piece of software is
dictated not only by the algorithms it employs, or the efficiency
with which those algorithms are coded,but also by how the
program utilizes memory (RAM).
Pool Allocators
● A pool allocator works by preallocating a large block of memory
whose size is an exact multiple of the size of the elements that will
be allocated.
● Each element within the pool is added to a linked list of free
elements; when the pool is first initialized, the free list contains all
of the elements. Whenever an allocation request is made, we
simply grab the next free element off the free list and return it.
When an element is freed, we simply tack it back onto the free list.
Both allocations and frees are O(1) operations, since each
involves only a couple of pointer manipulations, no matter how
many elements are currently free.
Memory Fragmentation
● When a program first runs, its heap memory is entirely free. When
a block is allocated, a contiguous region of heap memory of the
appropriate size is marked as “in use,” and the remainder of the
heap remains free. When a block is freed, it is marked as such,
and adjacent free blocks are merged into a single, larger free
block. Over time, as allocations and deallocations of various sizes
occur in random order, the heap memory begins to look like a
patchwork of free and used blocks. We can think of the free
regions as “holes” in the fabric of used memory. When the number
of holes becomes large, and/or the holes are all relatively small,
we say the memory has become fragmented.
Cache Coherency
● Accessing main system RAM is always a slow operation, often
taking thousands of processor cycles to complete. Contrast this
with a register access on the CPU itself, which takes on the order
of tens of cycles or sometimes even a single cycle. To reduce the
average cost of reading and writing to main RAM, modern
processors utilize a high-speed memory cache.
Containers
Game programmers employ a wide variety of collection-oriented data
structures, also known as containers or collections. The job of a
container is always the same—to house and manage zero or more
data elements; however, the details of how they do this varies greatly,
and each type of container has its pros and cons
Container Operations
Game engines that make use of container classes inevitably make use of
various commonplace algorithms as well.
Some examples include:
➔ Include
➔ Remove
➔ Sequential access
➔ Random access
➔ Find
➔ Sort
Iterators
● An iterator is a little class that “knows” how to efficiently visit the
elements in a particular kind of container. It acts like an array
index or pointer—it refers to one element in the container at a
time, it can be advanced to the next element, and it provides
some sort of mechanism for testing whether or not all elements in
the container have been visited.
● The key benefits to using an iterator over attempting to access
the con tainer’s elements directly are:
➔ Direct access would break the container class’
encapsulation. An iterator, on the other hand, is typically a
friend of the container class, and as such it can iterate
efficiently without exposing any implementation details to
the outside world.
➔ An iterator can simplify the process of iterating. Most
iterators act like array indices or pointers, so a simple loop
can be written in which the iterator is incremented and
compared against a terminating condition— even when the
underlying data structure is arbitrarily complex
Strings
The Problem with Strings
● How strings should be stored and managed in your program? In
C and C++, strings are implemented as arrays of characters. C++
programmers often prefer to use a string class, rather than deal
directly with character arrays.
String Classes
● String classes can make working with strings much more
convenient for the programmer. For example passing a string to a
function using a C-style character array is fast because the
address of the first character is typically passed in a hardware
register. On the other hand, passing a string object might incur
the overhead of one or more copy constructors, if the function is
not declared or used properly. Copying strings might involve
dynamic memory allocation.
● As a rule of thumb, always pass string objects by reference, never
by value
Unique Identifiers
● Unique object identifiers allow game designers to keep track of
the myriad objects that make up their game worlds and also
permit those objects to be found and operated on at runtime by
the engine.Strings seem like a natural choice for such identifiers.
Unicode
● ANSI strings work great for a language with a simple alphabet,
like English. But they just don’t cut it for languages with complex
alphabets containing a great many more characters, sometimes
totally diff erent glyphs than English’s 26 letters. To address the
limitations of the ANSI standard, the Unicode character set
system was devised.
UTF-8
● In UTF-8, the character codes are 8 bits each, but certain
characters occupy more than one byte. Hence the number of
bytes occupied by a UTF-8 character string is not necessarily the
length of the string in characters. This is known as a multibyte
character set (MBCS), because each character may take one or
more bytes of storage.
● Since the standard ANSI character codes are all less than 128, a
plain old ANSI string is a valid and unambiguous UTF-8 string as
well.
UTF-16
● Each character takes up exactly 16 bits. As a result, dividing the
number of bytes occupied by the string by two yields the number
of characters. This is known as a wide character set (WCS),
because each character is 16 bits wide instead of the 8 bits used
by “regular” ANSI chars.
● For strings, there are other details to worry about as well. You will
need to manage a database of all human-readable strings in
your game, so that they can all be reliably translated. The
software must display the proper language given the user’s
installation settings.
Engine Configuration
● Game engines are complex beasts, and they invariably end up
having a large number of configurable options. Some of these
options are exposed to the player via one or more options menus
in-game.