Understanding Game Programming Essentials
Understanding Game Programming Essentials
BCSE416L
[Link], SCOPE
WHY GAMING INDUSTRY IS
FLOURISHING?
• 69% of the global population has access to the internet.
• Recent estimates indicate about 3.3 billion gamers worldwide, which is “nearly half”
of the global population to be driven strongly by Asia’s roughly 1.5 billion gamers.
• Global research shows the typical internet user spends about 6 hours 38–40 minutes
online per day in 2024, which is roughly 46–47 hours per week.
• Global Average: On average, gamers worldwide spend about 13 USD per month
worldwide on online games.
• The gamers in North America will spend about 325 USD per year on games, which is
roughly 27 USD per month
• East Asian markets remain high‑spend, with 2025 projections putting average game
revenue per user at about 22 USD in Japan and around 31 USD in South Korea,
with South Korea among the highest in Asia.
WHAT IS A GAME?
• Movie? no interaction, outcome fixed ask: why not?
• Toy? no goal, but still fun (players can develop own goals) ask: why not?
• Puzzle? (has goal + interaction … ask: why not?)
strategy and outcome is the same each time
“A computer game is a software program in which one or more players
make decisions through the control of game objects and resources, in
pursuit of a goal.”
• Definitions
• Play - Interactions to elicit emotions
• Game - Object that provides rule-bound play
• Frame - The border of a game’s context
• Inside the frame is in the game
• Outside the frame is real life
• Aesthetics - Emotional responses during play
WHAT IS A GAME (2 OF 3)
• Has clear goals or win/lose/end conditions.
• Has explicit rules that restrict what players can and cannot do.
• Requires player input and decisions (meaningful choices).
• Provides feedback (score, health, progress bar, level clear, etc.).
• Includes challenge or conflict (against system, environment, or other
players).
• Is voluntarily entered and exited by the player.
• Runs inside a defined “magic circle” or boundary (game world, level, match).
• Can be digital or non‑digital (video games, board games, sports‑like games).
WHAT A GAME IS NOT (1 OF 2)
• A pure story or movie with no influence from the viewer is not a game.
• A software tool or utility (calculator, text editor, IDE) is not a game.
• A simulation that runs on its own with no player decisions is not a game.
• A toy or sandbox with no goals or constraints (just “playing around”) is not
a game in the strict design sense.
• A gambling or reward app where the user has no real choices (only presses
“spin” and waits) is closer to an interactive experience than a
well‑designed game.
“When a designer is asked how his game is going to make a difference, I hope he … talks
about gameplay, fun and creativity – as opposed to an answer that simply focuses on how
good it looks” – Sid Meier
SOME POPULAR GAMES
• Temple Run / Subway Surfers
• Goal: Run as far as possible, collect coins, beat high scores.
• Rules: Swipe to switch lanes/jump/slide; one hit = run ends.
• Choices: Risky coin paths vs safe paths; power-up usage.
• Feedback: Speed, coin count, distance, leaderboards, sound/visual cues.
• Clash Royale
• Goal: Destroy opponent’s towers; crown tower = auto win.
• Rules: Elixir system, card rotation, arena boundaries.
• Choices: Card placements, timing, elixir trade-offs.
• Feedback: Tower HP, elixir bar, trophies, chests.
• Syllabus
• DA 1: Review 1 – Game Concept Document Submission
• DA 2: Review 2 – Game Progress in PPT and half way game
demo
• DA 3: Review 3 – Game Full Demo with Game Design
Document
Module 1
INTRODUCTION TO GAME PROGRAMMING & GAME
ENGINE ARCHITECTURE
CORE COMPONENTS OF GAME ENGINE
• Rendering engine,
• Collision and physics engine,
• Animation system,
• Audio system, the game world object model,
• Artificial intelligence system, etc
Within each of these components, a relatively small number of semi-standard
design alternatives have also emerged
STRUCTURE OF A TYPICAL GAME TEAM
• Lead engineers usually still design and write code, but they also help to
manage the team’s schedule, make decisions regarding the overall technical
direction of the project.
• Some companies also have one or more technical directors (TD), whose job it
is to oversee one or more projects from a high level.
• The highest engineering-related position at a game studio is the chief
technical officer (CTO), if the studio has one (Eg: Nintendo (Japan),
Rockstar Games (USA), Valve Corporation (USA),etc.,)
ARTISTS
• In the game industry, “Content is king” . The artists produce all of the visual
and audio content in the game, and the quality of their work can literally make
or break a game.
• Artists come in all sort of flavors:
• Concept artists produce sketches and paintings that provide the team with a
vision of what the final game will look like.
• 3D modelers produce the three-dimensional geometry for everything in the
virtual game world. This discipline is typically divided into two subdisciplines:
foreground modelers and background modelers.
• Texture artists create the two-dimensional images known as textures, which
are applied to the surfaces of 3D models in order to provide detail and realism.
ARTISTS (CONTD…)
• Lighting artists lay out all of the light sources in the game world, both
static and dynamic, and work with color, intensity and light direction.
• Animators imbue the characters and objects in the game with motion.
• Motion capture actors are often used to provide a rough set of motion
data, which are then cleaned up and tweaked by the animators before being
integrated into the game.
• Sound designers work closely with the engineers in order to produce and mix
the sound effects and music in the game.
• Voice actors provide the voices of the characters in many games.
• Many games have one or more composers, who compose an original score
for the game.
Some game teams have one or more art directors—very senior artists who
manage the look of the entire game and ensure consistency across the work
of
GAME DESIGNERS
• The game designers’ job is to design the interactive portion of the player’s
experience, typically known as gameplay.
• Different kinds of designers work at different levels of detail.
• Some (usually senior) game designers work at the macro level, determining the
story arc, the overall sequence of chapters or levels, and the high-level goals and
objectives of the player.
• Other designers work on individual levels or geographical areas within the
virtual game world, laying out the static background geometry, determining where
and when enemies will emerge, placing supplies like weapons and health packs,
designing puzzle elements and so on.
GAME DESIGNERS (CONTD…)
• Some game teams employ one or more writers. A game writer’s job can
range from collaborating with the senior game designers to construct the
story arc of the entire game, to writing individual lines of dialogue.
• As with other disciplines, some senior designers play management roles.
Many game teams have a game director, whose job it is to oversee all
aspects of a game’s design, help manage schedules, and ensure that the
work of individual designers is consistent across the entire product.
PRODUCERS
• The line between a game and its engine is often blurry. Some engines make a
reasonably clear distinction, while others make almost no attempt to
separate the two.
• When a game contains hard-coded logic or game rules, or employs special-
case code to render specific types of game objects, it becomes difficult or
impossible to reuse that software to make a different game.
• We should probably reserve the term “game engine” for software that is
extensible and can be used as the foundation for many different games
without major modification.
ENGINE DIFFERENCES ACROSS GENRES
• Quake III Engine - id Tech 3, popularly known as the Quake III Arena engine,
is a game engine developed by id Software for their video game Quake III
Arena.
• Quake III Arena is a 1999 multiplayer-focused first-person shooter
developed by id Software.
• [Link]
GAME ENGINE HISTORY (CONTD)
First Person Shooter (FPS) Game Engine
Games like
• Unreal - [Link]
• Half-life - The Half-Life saga is the story of Gordon Freeman, a physicist who finds
himself at the center of resistance to an alien invasion that threatens the future of
humanity.
• Call of Duty – It is a military video game series and media franchise published by
Activision, starting in 2003. The games were first developed by Infinity Ward
• Focus on
• Efficient rendering of large 3d worlds
• Responsive camera control
• High-fidelity animations
• Cool weapons
• Forgiving physics model
GAME ENGINE HISTORY (CONTD)
• Third-person games
• Includes games like Ratchet and Clank (developed by Insomniac Games and
published by Sony Interactive Entertainment. a feline humanoid mechanic and
a diminutive, defective robot – as they travel through the universe, saving it
from evil forces that consistently threaten it. ) Developed for PS 2,3,4 and 5.
• [Link]
• Gears of War focuses on the conflict between humanity and the subterranean
reptilian humanoid. It is owned and published by Xbox Game Studios for Xbox
360..
• Focus on
• Puzzle like elements
• Moving environmental objects
• Third person follow camera
• Complex camera collision system
GAME ENGINE HISTORY (CONTD)
Fighting Games
• Games like Tekken (Iron Fist) - is a Japanese media franchise centered on a
series of fighting games developed and published by Bandai Namco
Entertainment, Fight Night- is a series of boxing video games created by EA
Sports. and Soul Calibur - Soulcalibur is a weapon-based fighting game
franchise developed by Bandai Namco Studios.
• Technology focus on
• Fighting animations
• Hit detection
• User input system
• Crowds
• Awesome character animations and shaders
• Physics based cloth and hair
GAME ENGINE HISTORY (CONTD)
Racing Games
• Games like Grand Turismo, Mario Kart, etc.,
• Technology tricks include
• Using simple cards for background objects
• Track is broken down into sectors
• Third-person and first person cameras
• Camera collision
GAME ENGINE HISTORY (CONTD)
Real-time Strategy
• Games like Warcraft, Starcraft, Age of Empires
• Technology involves
• Low resolution characters
• Height map based terrain
• Complex goal trees
• User interaction can take many forms, but reactivity is really important
GAME ENGINE HISTORY (CONTD)
MMOG
• A massively multiplayer online game (MMOG or more commonly MMO) is an online
video game with a large number of players to interact in the same online game world.
• Air Warrior was a multiplayer online combat flight simulation game launched by
Kesmai in 1987!!
• Games like World of Warcraft, Star Wars Galaxies, EverQuest
• Extra technology over 3rd person include
• Server side artifacts for
• Sign in/out
• State management
• Billing
• Client side rendering and state management
• Network layer for state consistency and cheat detection
GAME ENGINE HISTORY (CONTD)
Player-authored content
• Allowing the player to build content as part of the game
• Different from Mods
• Hardware
• This is the system that the game is to run on
• Device Drivers
• Shield the OS and upper layers from low level device communications
details
• Operating System
• Handles the execution and interruption of multiple programs on a single
machine
• Very thin on a console
3RD PARTY SDKS
• Data Structure and Algorithms
• STL – C++ standard template library data structures, strings, stream-based I/O
• Boost – powerful data structures and algorithms
• Boost libraries are intended to be widely useful, and usable across a broad
spectrum of applications. For example, they are helpful for handling large
numbers having range beyond the long long, long double data type (2 64) in
C++.
• Graphics
• OpenGL and DirectX
• Collisions and Physics
• Havok, PhysX, ODE, Bullet
• Character Animation
• Artificial Intelligence – Kynapse- An automatic AI data generation tool, Optimizations
for multicore/multiprocessing/Cell architectures
PLATFORM INDEPENDENCE LAYER
• Low-level
• Scene graph management
• Visual effects
• Front end
RENDERING
• Particle systems
• Decal systems
• Light mapping
• Dynamic shadows
• Full screen post effects
FRONT END
• HUD
• Menus
• GUI for character manipulation
• Full-motion video for cut scenes
PROFILING/DEBUGGING
• Code timing
• Display stats on the screen
• Dumping performance stats
• Determining memory usage
• Dumping memory usage
• Record and playback game events
• Print statement output control
COLLISIONS AND PHYSICS
• The event is passed to the receiver object by calling its event handler
function. Events can also be stored in a queue for handling at some future
time.
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. But when a scripting language is integrated into your engine,
changes to game logic and data can be made by modifying and reloading the
script code.
ARTIFICIAL INTELLIGENCE FOUNDATIONS
Any game
engine
must be
fed a
great deal
of data, in
the form
of game
assets,
configurat
ion files,
scripts,
etc.,
DIGITAL CONTENT CREATION TOOLS
• Game engines deal with data in many forms
• The data has to be created somehow
• 3D Meshes
• Textures
• Sound
• Animations
• The tools that the artists use are called digital content creation (DCC)
applications.
• Often created using outside tools
• Maya/3ds Max
• Photoshop
• SoundForge
Stand-alone tools architecture. Tools built on a framework shared with the game.
WEB BASED TOOLS
• Various uses
• Asset management
• Scheduling
• Bug management
• Easier to build
• Usually easier to build than a stand alone application
• Easier to update without forcing a reinstall
• If it just needs to present tabular data and have forms – use a web
interface
VERSION CONTROL
• A version control system is a tool that permits multiple users to work on a
group of files collectively. It maintains a history of each file so that changes can
be tracked and reverted if necessary.
• Why Use Version Control?
• Version control is crucial whenever software is developed by a team of multiple
engineers. Version control provides a central repository from which engineers
can share source code;
• keeps a history of the changes made to each source file;
• provides mechanisms allowing specific versions of the code base to be tagged
and later retrieved; and
• permits versions of the code to be branched off from the main development
line, a feature often used to produce demos or make patches to older versions
of the software.
ENGINE SUPPORT SYSTEMS
• Every game engine requires some low-level support systems that manage
mundane but crucial tasks, such as starting up and shutting down the
engine, configuring engine and game features, managing the
engine’s memory usage, handling access to file system(s), providing
access to the wide range of heterogeneous asset types used by the
game (meshes, textures, animations, audio, etc.), and providing debugging
tools for use by the game development team.
SUBSYSTEM START-UP AND SHUT-DOWN
• When the engine first starts up, each subsystem must be configured and
initialized in a specific order.
• Interdependencies between subsystems implicitly define the order in which
they must be started.
• If subsystem B depends on subsystem A, then A will need to be started up
before B can be initialized. Shut-down typically occurs in the reverse order,
so B would shut down first, followed by A.
DESIGN PATTERN
• When the same type of problem arises over and over, and many different programmers
employ a very similar solution to that problem, we say that a design pattern has arisen.
• Singleton. This pattern ensures that a particular class has only one instance (the
singleton instance) and provides a global point of access to it.
• Iterator. An iterator provides an efficient means of accessing the individual elements of
a collection, without exposing the collection’s underlying implementation. The iterator
“knows” the implementation details of the collection so that its users don’t have to.
• Abstract factory. An abstract factory provides an interface for creating families of related
or dependent classes without specifying their concrete classes.
NEED FOR SINGLETON CLASS FOR PROPER STARTUP AND SHUTDOWN
• In C++, global and static objects are constructed before the program’s entry
point (main(), or WinMain()) is called. However, these constructors are called
in a totally unpredictable order.
• The destructors of global and static class instances are called after main() (or
WinMain()) returns, and once again they are called in an unpredictable order.
• A common design pattern for implementing major subsystems such as the
ones that make up a game engine is to define a singleton class (often
called a manager) for each subsystem.
MEMORY MANAGEMENT
OPTIMIZING DYNAMIC MEMORY
ALLOCATION
• Memory affects performance in two ways:
• Dynamic memory allocation
• Memory allocation cost
• Memory access patterns
• Small data- continuous memory rather than spread across
OPTIMIZING DYNAMIC MEMORY
ALLOCATION (CONTD)
• Limitation
• Context-switch
• from user mode into kernel mode, process the request, and then context-switch back to
the program.
• How to overcome?
• custom allocator
• Satisfy requests from a preallocated memory block
• Runs in user mode alone
• Avoid the cost of context switch
STACK-BASED ALLOCATORS
• Allocate a large contiguous block
• A pointer to the top of the stack is maintained
• Major problem with dynamic heap allocations is that memory can become
fragmented over time.
• When the number of holes becomes large, and/or the holes are all relatively
small, we say the memory has become fragmented.
• The problem with memory fragmentation is that allocations may fail even
when there are enough free bytes to satisfy the request.
• Virtual memory can resolve this problem, but most of the game engines do
not make use of virtual memory.
MEMORY FRAGMENTATION
AVOIDING FRAGMENTATION WITH STACK
AND POOL ALLOCATORS
• A stack allocator is impervious to fragmentation because
allocations are always contiguous, and blocks must be freed in an order
opposite to that in which they were allocated.
• A pool allocator is also free from fragmentation problems. Pools
do become fragmented, but the fragmentation never causes premature
out of- memory conditions as it does in a general-purpose heap. Pool
allocation requests can never fail due to a lack of a large enough
contiguous free block, because all of the blocks are exactly the same
size.
AVOIDING FRAGMENTATION WITH STACK
AND POOL ALLOCATORS
CONTAINERS
What do Containers bring to the table that conventional development and deployment
methods don't?
• Extensive Portability: Containers allow you to move your application and its dependencies
between environments.
• Standardization: Using containerization tools (e.g. Docker) ensures more consistent
procedures of application deployment and implementation.
• Faster Deployment: Containers allow for developers to deploy to different environments with
less code changes or re-work to application code or configurations. Containers ensure that the
application in your local environment will work the same in any containerized environment you
deploy to.
• Deployment Flexibility: Containers allow teams to deploy to varying hosting environments.
That includes on-premise, public cloud or private cloud hosting environments.
• Eg: GameObjects are the fundamental objects in Unity that represent characters, props and
scenery. They do not accomplish much in themselves but they act as containers
for Components, which implement the real functionality.
CONTAINERS (CONTD..)
What do Containers bring to the table that conventional development and deployment methods
don't?
• Extensive Portability: Containers allow you to move your application and its dependencies
between environments.
• Standardization: Using containerization tools (e.g. Docker) ensures more consistent
procedures of application deployment and implementation.
• Faster Deployment: Containers allow for developers to deploy to different environments with
less code changes or re-work to application code or configurations. Containers ensure that the
application in your local environment will work the same in any containerized environment you
deploy to.
• Deployment Flexibility: Containers allow teams to deploy to varying hosting environments.
That includes on-premise, public cloud or private cloud hosting environments.
• Eg: GameObjects are the fundamental objects in Unity that represent characters, props and
scenery. They do not accomplish much in themselves but they act as containers
for Components, which implement the real functionality.
STRINGS
• String may seem like a simple, fundamental data type. But, when you start
using strings in your projects, you will quickly discover a wide range of
design issues and constraints.
• Problems with Strings:
• The most fundamental question about strings is how they should be stored
and managed in your program.
• In C and C++, strings aren’t even an atomic type—they are implemented as
arrays of characters.
• C++ programmers often prefer to use a string class, rather than deal directly
with character arrays.
STRINGS (CONTD..)
• localization—the process of adapting your software for release in other languages. This
is also known as internationalization.
• Any string that you display to the user in English must be translated into whatever
languages you plan to support.
• It also means ensuring that your game can handle different text orientations. For
example, traditional Chinese text is oriented vertically instead of horizontally.
• String operations are also expensive. Comparing strings requires an O(n) scan of the
character arrays using a function like strcmp().
• Conceptually, it’s easy enough to run a hash function on your strings in order to
generate string ids.
UNICODE
• The problem for most English-speaking software developers is that they are
trained from birth (or thereabouts!) to think of strings as arrays of eight-bit
ASCII character codes (i.e., characters following the ANSI standard).
• 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 different glyphs than
English’s 26 letters.
• To address the limitations of the ANSI standard, the Unicode character set
system was devised.
EXAMPLE FOR LOCALIZATION ISSUE