Download presentation
Presentation is loading. Please wait.
Published byRichard Newman Modified over 9 years ago
1
Chapter 3.6 Game Architecture
2
2 Overall Architecture The code for modern games is highly complex (can easily exceed 1M LOC) The larger your program, the more important it becomes to use a well- defined architecture
3
3 Overall Architecture Chapter bias: “conventional” videogames Main structure Game-specific code I will use “script”, but could be in C, etc. Game-engine code Presumably C/C++ from a 3 rd party Both types of code are often split into modules, which can be static libraries, DLLs, or just subdirectories
4
4 Overall Architecture Architecture types Ad-hoc (everything accesses everything) Modular (pretty much means OOP) DAG (directed acyclic graph; subsystems) Layered (fits engine+script mindset)
5
5 Overall Architecture Options for integrating “tools” into the architecture “tools” might mean: extra libraries that your game script code wants to make use of Separate code bases (if there's no need to share functionality) Partial use of game-engine functionality Full integration Extension hooks vs. programmable engine
6
6 Overview: Initialization/Shutdown The initialization step prepares everything that is necessary to start a part of the game The shutdown step undoes everything the initialization step did, but in reverse order
7
7 Overview: Initialization/Shutdown Resource Acquisition Is Initialization A useful rule to minimalize mismatch errors in the initialization and shutdown steps Means that creating an object acquires and initializes all the necessary resources, and destroying it destroys and shuts down all those resources
8
8 Overview: Initialization/Shutdown Optimizations Fast shutdown Warm reboot
9
9 Overview: Main Game Loop Games are driven by a game loop that performs a series of tasks every frame Some games have separate loops for the front (UI) and the game sim itself Other games have a unified main loop
10
10 Overview: Main Game Loop Tasks Handling time Gathering player input Networking Simulation Collision detection and response Object updates Rendering Other miscellaneous tasks
11
11 Overview: Main Game Loop Structure Hard-coded loops Multiple game loops For each major game state Consider steps as tasks to be iterated through
12
12 Overview: Main Game Loop Coupling Can decouple the rendering step from simulation and update steps Results in higher frame rate, smoother animation, and greater responsiveness Implementation is tricky and can be error- prone
13
13 Overview: Main Game Loop Execution order Most of the time it doesn't matter In some situations, execution order is important Can help keep player interaction seamless Can maximize parallelism Exact ordering depends on hardware
14
14 Game Entities What are game entities? Basically anything in a game world that can be interacted with More precisely, a self-contained piece of logical interactive content Only things we will interact with should become game entities
15
15 Game Entities Organization Simple list Multiple databases Logical tree Spatial database
16
16 Game Entities Updating Updating each entity once per frame can be too expensive Can use a tree structure to impose a hierarchy for updating Can use a priority queue to decide which entities to update every frame
17
17 Game Entities Object creation Basic object factories Extensible object factories Using automatic registration Using explicit registration
18
18 Game Entities Level instantiation Loading a level involves loading both assets and the game state It is necessary to create the game entities and set the correct state for them Using instance data vs. template data
19
19 Game Entities Identification Strings Pointers Unique IDs or handles
20
20 Game Entities Communication Simplest method is function calls Many games use a full messaging system Need to be careful about passing and allocating messages
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.