Games Development Game Architecture: Entities

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:
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.
Use cases and requirement specification - 1 Use case diagrams 3 use cases System boundaries Remember: Use case diagramming is a tool, not the requirements.
© Copyright Eliyahu Brutman Programming Techniques Course.
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 Game Architecture. Overall Architecture The code for modern games is highly complex With code bases exceeding a million lines of code, a well-defined.
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.
1 BTEC HNC Systems Support Castle College 2007/8 Systems Analysis Lecture 9 Introduction to Design.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Laurent Noel.
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.
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.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
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,
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
CE Operating Systems Lecture 17 File systems – interface and implementation.
M1G Introduction to Programming 2 5. Completing the program.
Games Development 1 Review / Revision CO2301 Games Development 1 Semester 2.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Microsoft Foundation Classes MFC
OOP - Object Oriented Programming
CompSci 280 S Introduction to Software Development
Games Development Practices 3D Modelling
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
CO Games Development 2 Week 16 Blackboard Model
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.
Where are we ? Setup Sprites Input Collision Drawing Sprites
Week 2 - Monday CS361.
Roberta Roth, Alan Dennis, and Barbara Haley Wixom
The Movement To Objects
Systems Analysis and Design
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
System Design and Modeling
Games Development 2 semester 1 Review & Revision
Distribution and components
Software Design Mr. Manoj Kumar Kar.
CHAPTER 3 Architectures for Distributed Systems
Abstract descriptions of systems whose requirements are being analysed
CO Games Development 2 Week 19 Extensions to Finite State Machines
File Systems and Databases
Chapter 6 – Architectural Design
Writing up your Project
Games Development Practices 3D Model Import/Export
Week 6: Time and triggers!
Games Development Practices Semester 2 Overview
Use Case Analysis – continued
Unity Game Development
Games Development 2 Tools Programming
Games Development 1 Review / Revision
Games Development 2 Entity / Architecture Review
Lecture-Hashing.
Presentation transcript:

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

Today’s Lecture Game Architecture: Beyond 3D Entities Entity Content Entity Architecture Update 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): 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 Character ID Mesh Animations Position / Rotation Max Hit Points Hit Points Script 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 3rd 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