0% found this document useful (0 votes)
14 views101 pages

Understanding Game Programming Essentials

The document discusses the flourishing gaming industry, highlighting that nearly half of the global population are gamers, with significant spending on games, especially in North America and East Asia. It defines what constitutes a game, outlining its essential components, and distinguishes it from non-game experiences. Additionally, it covers the structure of game development teams, the roles of engineers, artists, designers, and producers, as well as the history and evolution of game engines across various genres.

Uploaded by

Charan sai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views101 pages

Understanding Game Programming Essentials

The document discusses the flourishing gaming industry, highlighting that nearly half of the global population are gamers, with significant spending on games, especially in North America and East Asia. It defines what constitutes a game, outlining its essential components, and distinguishes it from non-game experiences. Additionally, it covers the structure of game development teams, the roles of engineers, artists, designers, and producers, as well as the history and evolution of game engines across various genres.

Uploaded by

Charan sai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

GAME PROGRAMMING

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.

• BGMI / PUBG / Free Fire


• Goal: Be the last survivor/squad.
• Rules: Shrinking circle, loot rules, weapon stats, damage model.
• Choices: Landing spot, engagement vs stealth, loadout, positioning.
• Feedback: Kill feed, hit markers, rank, match summary, progression.
SOME POPULAR GAMES (CONTD..)

• 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.

“These games succeed because player choices matter inside a well-defined


system.”
SYLLABUS AND DIGITAL ASSIGNMENTS

• 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

• Engineers, artists, game designers, producers and other management and


support staff (marketing, legal, information technology/technical support,
administrative, etc.)
• Developers
• Publishers
• Distributors
• Retailers

• Much like a mini-Hollywood


ENGINEERS
• The engineers design and implement the software that makes the game, and the
tools, work.
• Engineers are often categorized into two basic groups: runtime programmers
(who work on the engine and the game itself) and tools programmers
(who work on the offline tools that allow the rest of the development team to work
effectively).
• Some engineers focus their careers on a single engine system, such as rendering,
artificial intelligence, audio or collision and physics.
• Some focus on gameplay programming and scripting, while others prefer to work
at the systems level and not get too involved in how the game actually plays.
• Some engineers are generalists—jacks of all trades who can jump around and
tackle whatever problems might arise during development.
ENGINEERS (CONTD…)

• 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 role of producer is defined differently by different studios. In some game


companies, the producer’s job is to manage the schedule and serve as a
human resources manager.
• In other companies, producers serve in a senior game design capacity. Still
other studios ask their producers to serve as liaisons between the
development team and the business unit of the company (finance, legal,
marketing, etc.).
OTHER STAFF
• The team of people who directly construct the game is typically supported by
a crucial team of support staff.
• This includes the studio’s executive management team, the marketing
department, administrative staff and the IT department, whose job is to
purchase, install and configure hardware and software for the team and to
provide technical support.
PUBLISHERS AND STUDIOS

• The marketing, manufacture and distribution of a game title are usually


handled by a publisher, not by the game studio itself. A publisher is typically
a large corporation, like Electronic Arts, THQ, Vivendi, Sony, Nintendo, etc.
• Many game studios are not affiliated with a particular publisher. They sell
each game that they produce to whichever publisher strikes the best deal
with them.
GAME ENGINE
• The term “game engine” arose in the mid-1990s in reference to
first-person shooter (FPS) games like the insanely popular Doom
by id Software.
• The player assumes the role of a space marine, later unofficially
referred to as Doomguy, fighting through hordes of undead
humans and invading demons.
• The game begins on the moons of Mars and finishes in hell, with
the player traversing each level to find its exit or defeat its final
boss. It is an early example of 3D graphics in video games, and
has enemies and objects as 2D images, a technique sometimes
referred to as 2.5D graphics.
ABOUT LICENCING AND MODDING
• Doom was architected with a reasonably well-defined separation
between its core software components (such as the three-
dimensional graphics rendering system, the collision detection
system or the audio system) and the art assets, game worlds and
rules of play that comprised the player’s gaming experience.
• The value of this separation became evident as developers began
licensing games.
• This marked the birth of the “mod community”—a group of
individual gamers and small independent studios that built new
games by modifying existing games, using free toolkits provided
by the original developers.
• Eg: Quake III Arena
GAME AND GAME ENGINE

• 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

• Game engines are typically somewhat genre specific. An engine designed


for a two-person fighting game in a boxing ring will be very different from a
massively multiplayer online game (MMOG) engine or a first-person shooter
(FPS) engine (First-person refers to the view where the players see the world
from the eyes of their characters) or a real-time strategy (RTS) engine.
GAME ENGINE HISTORY
GAME ENGINE HISTORY
Pac-Man, originally
called Puck Man in
Japan by Toru Iwatani,
is a 1980
maze video game
developed and
released by Namco for
arcades.

The game remains one of the


highest-grossing and best-
selling games, generating
more than $14 billion in
revenue
GAME ENGINE HISTORY (CONTD)
• Hydro Thunder is an arcade inshore powerboat racing video game
originally released by Midway Games in February 1999.
• The gameplay of Hydro Thunder is similar to Sega's Daytona USA. It
consists of racing high-tech speedboats through treacherous
environments, from the cold seas of the Arctic Circle to a post-apocalyptic
version of New York City.
• The arcade version of Hydro Thunder utilizes the same basic cabinet as
Midway's earlier Hyperdrive, and was also sold as a conversion kit for that
game. It has the same cabinet seat as Atari’s San Francisco Rush. It also
has the same steering wheel on the control panel as Cruis'n USA, minus
the standard foot pedals, and adds a variable position throttle with
forward, neutral and reverse directions.

Different versions are made for


Sega Dreamcast - It is the final home video game console manufactured by Sega (US)
Midway Games - was an American video game developer and publisher. (US)
PlayStation - It is a home video game console developed and marketed by Sony Computer
Entertainment. (Japan)
Nintendo 64 - Nintendo 64 (N64) is a home video game console developed and marketed by Nintendo
GAME ENGINE HISTORY (CONTD)

• 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

• Good example include


• Little Big Planet series (LittleBigPlanet is a puzzle platform video game series created and
produced by British developer Media Molecule and published by Sony Interactive
Entertainment. Most games in the series put a strong emphasis on user-generated content
and are based on the series' tagline "Play, Create, Share“)
• Minecraft (Minecraft is a 2011 sandbox game developed and published by Mojang Studios)

• Fun is in sharing with others


• Simplicity is key
SOME CURRENT ENGINES
• Quake family
• Used to create many games
• Has lineage that extends to modern games like Medal of Honor
• Quake and Quake II engines source code are freely available
• Unreal Engine
• Now at UE4
• Very rich tool set – Kismet
• Large developers network
• Good licensing model – good for small developers
MORE ENGINES
• Unity • CryEngine
• Very feature rich Originally developed as a demo
for Nvidia
• Uses Javascript or C# for scripting Used to develop numerous
• Large community support games – starting with Far Cry
• Great for cross-platform development
• Sony PhyreEngine
• Source Engine Uses to create games for the
• Games like Half-life 2 and its sequels, Team Sony platforms
Numerous titles have been
Fortress 2, and Portal
written with this engine
• Very powerful with good graphics capabilities and
a good toolset • Microsoft XNA and MonoGame
Based on C# - easy to use
• DICE’s Frostbite Used for Xbox and PC games
• Used to create games like Battlefield 4 Not longer supported – replaced
• FrostEd – asset creation tool by MonoGame
2D ENGINES

• Designed for non-programmers to build apps for Android and


iPhone
• Examples include
• Multimedia Fusion 2
• Game Salad Creator
• Scratch
GAME ENGINE ARCHITECTURE

Runtime Engine Architecture


• Consists of the tools suite and runtime
components
• Large
• Spans hardware to high-level
application
• Designed in layers
• Avoids circular dependencies to
maximize reuse and testability
RUN TIME ENGINE
• Low level components
• 3rd Party SDKs
• Platform independence layer
• Core systems
• Resources manager
• Rendering engine
• Profiling/Debugging
• Collisions and Physics
• Animation
• Human Interface Devices
• Audio
• Gameplay foundation system
LOW LEVEL COMPONENTS

• 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

•Allows the engine to be developed without the


concern of the underlying platform
•Provides wrappers to common target specific
operations
•Include things like primitive types, network, file
systems, etc.
CORE SYSTEMS

• Assertions – error checking code


• Memory Management
• Math library – vector and matrix math, numeric integrators
• Custom data structures
RESOURCE MANAGER

• Provides a unified interface for accessing assets


• The level of complexity is dictated by need
• Often the game programmers must do resource loading directly
• Engines like UT do unpackaging and complex manipulation of assets in the engine
RENDERING ENGINE

• Low-level
• Scene graph management
• Visual effects
• Front end
RENDERING

• Modeling is the mathematical specification of shape and


appearance properties in a way that can be stored on the
computer
• Rendering is creation of shaded images from 3d computer
models
• Animation is a technique to create an illusion of motion
through a sequence of images. Handling time is a key issue
in animation
GRAPHICS OBJECTS
• Gameobjects- Anything to which components are attached
• Aggregation of other game objects
• Canvas – It is user interface which is normally the top most layer displaying the
game scores
• Layer – The various layers that hold gameobjects together
• Layer 0 has the full visibility
• Other layers may be occluded(hidden) based on the objects in other layers
• Sprite-are simple 2D objects that have graphical images (called textures) on
them. Whenever Unity makes a new sprite, it uses a texture. This texture is
then applied on a fresh GameObject, and a Sprite Renderer component is
attached to it.
• A renderer is what makes an object appear on the screen. Use this class to
access the renderer of any object, mesh or Particle System. Renderers can be
disabled to make objects invisible (see enabled)
LOW-LEVEL RENDERER
• Focuses on rendering primitives as quickly and richly as possible
• Does not consider visibility
• Graphics Device Interface
• Access and enumerate the graphics devices
• Initialize the GD
• Setup buffering
• Others
• Representation of the geometric primitives
• Abstraction of the camera interface
• Material system
• Dynamic lighting system
• Text and fonts
SCENE GRAPH

• Limits the number of primitives submitted for rendering


• Uses frustum culling – remove things outside of the visible screen
• Spatial subdivision
• BSP, quadtree, octree, kd-tree
VISUAL EFFECTS

• 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

• Usually rigid body dynamics


• Physics engine creation is its own unique undertaking
• Many companies use available libraries
• Havok
• PhysX
• ODE
• Bullet
ANIMATION

• Five types of animation are used


• Sprite/texture animation
• Rigid body hierarchy animation
• Skeletal animation (Skeletal animation
permits a detailed 3D character mesh to be
posed by an animator using a relatively
simple system of bones. As the bones move,
the vertices of the 3D mesh move with them.)
• Vertex animation
• Morphing
• Skeletal animations still the most
popular
HUMAN INTERFACE DEVICES

• Keyboard and mouse abstractions


• Joypads
• Specialized controllers
• Massages raw data into useful information
AUDIO

• Often overlooked until the end


• Varies in sophistication based on need
• Many games use existing tools
• XACT
• Scream
MULTIPLAYER/NETWORKING

• Four main flavors


• Single screen – multiple players on the same screen
• Split-screen multiplayer – multiple perspectives on the
same screen
• Networked multiplayer – multiple computers networked
together
• Massive multiplayer online games – run in a central server
• Difficult to convert single to multiplayer, easy to do the
opposite
GAMEPLAY FOUNDATION SYSTEM

• Most everything that makes the game a game


• World loading
• Game object model
• Static world elements
• Real-time agent simulations
EVENT SYSTEM

• Objects need to communicate with one another


• Easiest to handle this through a common system
• Objects send messages that are routed to the event handler
• 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. 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

• Provides AI building blocks


• Path planning
• Nav mesh generation
• Object avoidance
• Autodesk has a middleware called Gameware that provides
many of these features
GAME-SPECIFIC SUBSYSTEMS

• All of the specific stuff needed for a game


• This layer could be considered outside of the game engine itself
TOOLS AND THE ASSET PIPELINE

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

• DCC tools need to be easy to use and very reliable


ASSETS CONDITIONING PIPELINE
• DCC tools produce a variety of file formats that are not optimized for game
• Game engines usually store the data in an easy to read and platform specific
format
• The data formats used by digital content creation (DCC) applications are
rarely suitable for direct use in-game.
• The pipeline from DCC app to game engine is sometimes called the Asset
Conditioning Pipeline (ACP).
CONDITIONING ASSETS
• 3D Model/Mesh data
• 3D Models – Must be properly tessellated (pattern of
repeated shapes)
• Brush Geometry – A collection of convex hulls with multiple
planes
• Skeletal animation data
• Must be compressed and converted to properly work
• Audio data
• Should convert multiple formats to a single format for the
target system
• Particle system data
GAME WORLD EDITOR
• Usually integrated into the engine
• Essential to allow game designers to work with the engine
• Many examples
• UnrealEd
• Hammer
• Radiant
RESOURCE DATABASE

• Need a way to store and manage the vast amounts of data


• Some companies use relational databases
• MySQL or Oracle

• Some companies use version control software


• Subversion, Perforce, or GIT

• Still others use custom software


• Naughty Dog uses a custom GUI called Builder
APPROACHES TO TOOL ARCHITECTURE

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

Figure – Stack allocation and freeing


back to a marker
DOUBLE-ENDED STACK ALLOCATORS

• A single memory block can actually contain two stack allocators

• Eg: Hydro Thunder


• The bottom stack is used for loading and unloading levels (race tracks)
• The top stack is used for temporary memory blocks that are allocated and
freed every frame.
• This allocation scheme worked extremely well and ensured that Hydro
Thunder never suffered from memory fragmentation problems
POOL ALLOCATORS

• Applications which require lots of small blocks of memory during


runtime.
• Preallocating a large block of memory whose size is an exact
multiple of the size of the elements that will be allocated
• A pool allocator allocates a chunk of memory once, and divides
that memory into slots/bins/pools which fit exactly M instances
of size N
POOL ALLOCATORS - EXAMPLE

• As an example, consider we want to have a maximum of 256 bullets in flight


at the same time, each bullet having a size of 32 bytes.
• Thus, the pool allocator would allocate 256*32 = 8192 bytes once, dividing it
into slots which are then used for allocating/freeing objects of size 32.
SINGLE-FRAME AND DOUBLE-BUFFERED
MEMORY ALLOCATORS

• All game engines allocate at least some temporary data


during the game loop. This data is either discarded at the
end of each iteration of the loop or used on the next
frame and then discarded. This allocation pattern is so
common that many engines support single- and double-
buffered allocators
SINGLE-FRAME ALLOCATORS

• Implemented by stack based allocator


• At the beginning of each frame, the stack’s “top” pointer is cleared to the
bottom of the memory block. The allocator will be cleared at the start of
every frame
Limitation
• Memory block allocated out of the single-frame buffer will only be valid
during the current frame
DOUBLE-BUFFERED ALLOCATORS

• A double-buffered allocator allows a block of memory allocated on frame i to


be used on frame (i + 1).
• For example, memory allocated during frame n is cleared at the end of
frame n + 1, and those allocated during frame n + 1 will be cleared at the
end of frame n + 2.
• This allows us to nicely pass information to the next frame without worrying
about leaking memory long-term.
• It will come in handy for things like velocity calculations, which are things
that require us to know the position of the object in the last frame.
MEMORY FRAGMENTATION

• 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

• Containers allow you to move your application to different environments


without making changes, keeping your dependencies intact. It allows for
reduced migration efforts, quicker deployments, and freedom to move your
application anywhere you desire.
CONTAINERS IN UNITY
In Unity game programming, the term "containers" can refer to several distinct concepts:
• Data Containers (Collections):
It refers to data structures used to store and organize collections of data, such as:
•Arrays
•Lists (List<T>)-flexible
•Dictionaries (Dictionary<TKey, TValue>)
•Native Containers (Job System): Specific data structures
like NativeArray<T>, NativeList<T>, and NativeHashMap<TKey,
TValue> designed for use with Unity's Job System and Burst
Compiler. These containers are optimized for performance in
multithreaded environments and require manual memory management.
• Dependency Injection (DI) Containers / IoC Containers:

These are software frameworks or patterns used to manage and inject


dependencies between different parts of your code. They help decouple components,
making your code more modular, testable, and maintainable.
CONTAINERS IN UNITY (CONTD..)

• Game Object Containers:


This refers to the practice of using an empty GameObject in the Unity Hierarchy to
group and organize other related GameObjects as its children. This helps in scene
organization, managing transformations (position, rotation, scale) of a group of objects
together and enabling/disabling entire sections of your scene easily.

• Container Builds (for Game Server Hosting):


When hosting multiplayer game servers using services like Unity Multiplay Hosting
or Amazon GameLift, "containers" often refer to Docker containers. These package
your game server executable and all its dependencies into a single, isolated unit,
ensuring consistent deployment and execution across different environments.
You build a container and then deploy it to a container registry for distribution to server
instances.
DOCKER
• A Docker container is a lightweight, standalone, and executable software
package that includes everything needed to run an application: code,
runtime, system tools, system libraries, and settings.
• Containers isolate software from its environment, ensuring consistent
behavior regardless of the underlying infrastructure.
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.
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

• For example, let’s say you want a heads-up display


that lists the score of each player with “Player 1
Score:” and “Player 2 Score:”labels and that also
displays the text “Player 1 Wins” or “Player 2 Wins”
atthe end of a round.
• These four strings would be stored in the
localization database under unique ids that are
understandable to you, the developer of the game.
So our database might use the ids “p1score,”
“p2score,” “p1wins” and “p2wins,” respectively.
• Once our game’s strings have been translated into
French, our database would look something like the
simple example shown

You might also like