Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Object-Oriented Analysis and Design
How do games work? Game Workshop July 4, Parts Sprites/pictures Map/background Music/sounds Player character Enemies Objects.
Managing data Resources: An information system provides users with timely, accurate, and relevant information. The information is stored in computer files.
PHP (2) – Functions, Arrays, Databases, and sessions.
Delegates & Events Observer and Strategy Patterns Game Design Experience Professor Jim Whitehead January 30, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0.
Use cases and requirement specification - 1 Use case diagrams 3 use cases System boundaries Remember: Use case diagramming is a tool, not the requirements.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
© Copyright Eliyahu Brutman Programming Techniques Course.
Use Case Analysis – continued
Chapter 3.6 Game Architecture. 2 Overall Architecture The code for modern games is highly complex With code bases exceeding a million lines of code, a.
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Chapter 3.4 Game Architecture. Overall Architecture The code for modern games is highly complex With code bases exceeding a million lines of code, a well-defined.
Games Development Practices Semester 2 Overview CO2301 Games Development 1 Week 14.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
CHAPTER 17 Creating an Interactive 3D Environment © 2008 Cengage Learning EMEA.
C++ fundamentals.
Chapter Languages, Programming and Architecture.
Games Development 2 Entity / Architecture Review CO3301 Week
Dakota Humphries (Project Lead) Thomas Impellitteri (Tech Lead) Daryl McGhee II (Design Lead) Keith Rosier (Asset Lead)
CSE 381 – Advanced Game Programming 3D Game Architecture.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
1 BTEC HNC Systems Support Castle College 2007/8 Systems Analysis Lecture 9 Introduction to Design.
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
Games Development 2 Resource Management CO3301 Week 3.
10/9/20151 Unreal Basics CIS 488/588 Bruce R. Maxim UM-Dearborn.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Emotional Models in Games Max Douglas Chris Zhu Tania Tam Luke.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Games Development 2 Component-Based Entities
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Games Development 2 Review & Revision Strategy CO3301 End of Semester 1.
Application of AI techniques for Computer Games BSc Computer Games Programming, 2006 Julien Delezenne GAMES ARTIFICIAL INTELLIGENCE.
Games Development 2 Overview & Entity IDs and Communication CO3301 Week 1.
Chapter 3.6 Game Architecture. 2 Overall Architecture The code for modern games is highly complex (can easily exceed 1M LOC) The larger your program,
Distributed Virtual Environment and Simulation Package Stephen Lawrence
Dakota Humphries (Project Lead) Thomas Impellitteri (Tech Lead) Daryl McGhee II (Design Lead) Keith Rosier (Asset Lead)
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
M1G Introduction to Programming 2 5. Completing the program.
Games Development 1 Review / Revision CO2301 Games Development 1 Semester 2.
Computer Graphics Matrix Hierarchies / Animation
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Game program main loop.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Dr Nick Mitchell (Room CM 224)
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
General Architecture of Retrieval Systems 1Adrienn Skrop.
Microsoft Foundation Classes MFC
OOP - Object Oriented Programming
CompSci 280 S Introduction to Software Development
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
The Movement To Objects
Game Architecture Rabin is a good overview of everything to do with Games A lot of these slides come from the 1st edition CS 4455.
Object-Oriented Analysis and Design
Games Development 2 semester 1 Review & Revision
CHAPTER 3 Architectures for Distributed Systems
Use Case Analysis – continued
Games Development Game Architecture: Entities
Games Development 2 Tools Programming
Games Development 1 Review / Revision
Games Development 2 Entity / Architecture Review
Presentation transcript:

Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22

Today’s Lecture 1.Game Architecture: Beyond 3D 2.Entities 3.Entity Content 4.Entity Architecture 5.Update 6.Identification & Communication

Game Architecture: Beyond 3D Previously looked at 3D engine architecture –Advice relevant for other parts of the game structure (interfaces, factory functions etc.) Now, consider other program components: –Game Logic / Data, AI, Physics, Networking, Sound etc. Some have well understood architectures –Networking, physics and other hardware interfaces –Rather specialist and beyond the scope of this module Other components are very game specific and their architecture varies greatly –Game logic / data, AI

Entities All games are similar in that they manage a collection of entities, sometimes called actors The architecture of the game-play code is driven by the architecture of these entities What is an entity? –A single game element –Self-contained - not part of another entity –Interactive – needs to be updated periodically Examples: –A character (or NPC), monster or vehicle etc. –Objects (pick-ups or interactive scenery), triggers –Cameras, lights, particle systems, level geometry (?)

Entity Common Features What features do all entities have in common? –Can be instantiated in the game (i.e. created) – at set-up time, when loading a game or upon a game event –Need to be updated periodically –They can be uniquely identified Other features shared by sub-classes of entities –Some can be positioned in the scene –Many have a visual representation (mesh, animations) Can be rendered –Most have attributes, statistics or state –Can often interact with other entities –Complex entities can have scripted behaviour

Entity Classes This suggests that Entities form a class hierarchy The exact hierarchy will depend on the needs of the game Here’s an example:

Entity Content E.g. Consider a Character object (a kind of Entity): Character ID Mesh Animations Position / Rotation Max Hit Points Hit Points Script This is rather like an IModel as used in the TL-Engine –An instance of a mesh with positioning –We could render this But it contains game data too - it can be used by the AI and game logic This is a general character class, we may inherit more specific versions E.g. A Wizard class may be a Character with additional stats (MP) and some extra script

Entity Templates However, imagine 500 of these characters –The mesh, animation, max HP and script are constant –This data will be duplicated 500 times So we divide the entity data: –The entity template has common data for all entities –The entity instance contains data for a specific entity Character Instance 1 ID Position / Rotation Hit Points Character Instance 2 ID Position / Rotation Hit Points Character Template Mesh Animations Max Hit Points Script

Architecture for Entities 1 How to store entities in our game? Keep a central list of entities somewhere –In an entity manager (recall manager classes) –Entities are dynamic, a list allows insertion / deletion Can step through this list every frame to update / render / perform AI on entities –Bad idea, not all entities are renderable or have AI –Also, some might not be visible, or be inactive –Nor will all entities need to be updated every frame, e.g. distant or hidden entities (see later) Maybe we need a different structure…

Architecture for Entities 2 Every game is different with regards entity organisation –An RTS might arrange entities in a grid –An FPS might use a quadtree A 3D spatial subdivision – will see in 3 rd year Different components of the same game may actually have different organisational needs –Renderer / Collision detection / AI Might organise entities into many structures simultaneously –E.g. Store a list in a scene manager –Have a quadtree and a grid structure, both containing pointers to entities in the overall list

Entity Update 1 Each entity will have an Update function –To perform AI, run scripts, trigger events etc. –Exact tasks depend on the entity –Using classes / polymorphism here One update function per entity type, not just one for the entire scene Can update the entire list of entities each frame –Will use a timed game loop However, not all entities need to be updated –i.e. distant or inactive entities Need to make a decision about importance of each entity, before deciding to update

Entity Update 2 Can use a priority queue to do decide which entities to process each frame –Entities are placed in the queue depending on how long before they need their next update –Distant / inactive entities go at the end –Nearby / important entities go at the front Step through the queue: –Update each entity and put back on the queue with an updated time –Stop on first entity that doesn’t need an update this frame –This process updates the minimum number of entities

Entity Rendering We usually give each entity a render function This is called every frame –May do nothing if entity is not visible (e.g. a sound) Typically, the entity instance passes its current position / animation etc. to its entity template –The entity template can render any of its own instances given these specifics –Recall that the template stores the mesh This is fairly similar to model/mesh rendering –Entity template – similar to mesh –Entity instance – similar to model

Entity Identification Each entity needs a unique identifier so we can refer to it during the game We could give each a name (a string) –Not so efficient, especially for look-up Or we could use a pointer to the entity –Like a IModel* in the TL-Engine –Difficult to update pointers when entity is destroyed Better to use a UID, a unique identifier for an entity –Usually just as a simple integer Then provide a system to map UIDs to entities –A hash map or similar, must be efficient

Entity Communication Entities can communicate by calling each other’s member functions –E.g. “PickUp”, “EmitSound” –But this increases class coupling - makes the game less flexible Better to implement a messaging system –An entity can send a message to another entity (addressed with its name or UID) –Messages are distributed by the game system –Entities pick up their messages during their update function and decide what (if anything) to do with them Very flexible system –Similar to network communication