Additional Design Patterns for Games For CSE 3902 Matt Boggus.

Slides:



Advertisements
Similar presentations
Design Validation CSCI 5801: Software Engineering.
Advertisements

AP Computer Science A – Healdsburg High School 1 Unit 3 - Classes and Objects - Example.
Teaching with Greenfoot
ITEC 370 Lecture 12 Design. Review Questions? Design patterns –How useful are they? –Command pattern What is it? What can it do for you?
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
CS 4730 Game Design Patterns CS 4730 – Computer Game Design Credit: Some slide material courtesy Walker White (Cornell)
How do games work? Game Workshop July 4, Parts Sprites/pictures Map/background Music/sounds Player character Enemies Objects.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Chapter 3.7 Memory and I/O Systems. 2 Memory Management Only applies to languages with explicit memory management (C or C++) Memory problems are one of.
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.
Lua & Love2D Game Engine GALAGUH
CSE 380 – Computer Game Programming AI & Collision Strategy Erin Catto’s Box2D.
Chapter 3 Memory Management: Virtual Memory
Zhonghua Qu and Ovidiu Daescu December 24, 2009 University of Texas at Dallas.
By Yukyong Chung.  Given the terms of computational concepts, the students will be able to state examples matching the Scratch blocks.  The students.
Games Development 2 Resource Management CO3301 Week 3.
CSSE 374: Introduction to Gang of Four Design Patterns
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
A Framework for Elastic Execution of Existing MPI Programs Aarthi Raveendran Graduate Student Department Of CSE 1.
Web Games Programming An Introduction to Unity 3D.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
School of Computer Science & Information Technology G6DICP - Lecture 17 GUI (Graphical User Interface) Programming.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Games Development 2 Component-Based Entities
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Object Oriented Software Engineering Chapter 16 and 17 review 2014/06/03.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
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,
Guide to Programming with Python Week 15 Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
08 - StructuralCSC4071 Structural Patterns concerned with how classes and objects are composed to form larger structures –Adapter interface converter Bridge.
Structural Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
1 CSC 221: Computer Programming I Spring 2008 course overview  What did we set out to learn?  What did you actually learn?  Where do you go from here?
Object Oriented Analysis & Design Game Patterns. Contents  What patterns are  Delegation  Game Loop  Scene Graph  Double Buffering  Component 
1 CSE 331 Model/View Separation and Observer Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia.
Interface Patterns. Adapter Provides the interface a client expects, using the services of a class with a different interface Note Avoid using object.
Introduction to OOP CPS235: Introduction.
The Memento Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
Construct 2 Game Development for Kids Platformer Tutorial: Part 1 Shahed Chowdhuri.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
Creating an Object that can draw itself The paint method can ‘draw’ because it is passed a graphics environment as a parameter. If a class method is passed.
OOP - Object Oriented Programming
Additional Design Patterns for Games
Visit for more Learning Resources
Where are we ? Setup Sprites Input Collision Drawing Sprites
3GB3 Game Design Unity 3D Basics.
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.
MPCS – Advanced java Programming
CSC 221: Computer Programming I Spring 2010
Introduction to Design Patterns
CSC 221: Computer Programming I Fall 2005
Task Scheduling for Multicore CPUs and NUMA Systems
Decorator Design Pattern
Design Patterns in Game Design
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
2D Collision Response For CSE 3902 By: Matt Boggus.
Design Patterns Part 2: Factory, Builder, & Memento
Presentation made by Steponas Šipaila
Designing For Testability
Games Development 2 Entity / Architecture Review
Presentation transcript:

Additional Design Patterns for Games For CSE 3902 Matt Boggus

Flyweight An object that minimizes memory use by sharing as much data as possible with other similar objects Frequently used in graphical applications – Font file – Image file for sprite drawing – 3D model file

Flyweight example – 3D tree model Instances Instances with shared 3D model Images from gameprogrammingpatterns.com

Flyweight example – level tiling Image from gameprogrammingpatterns.com

Object pool Use a set of initialized objects kept ready to use (a pool) instead of allocating and destroying them on demand. Allocation -> request an object from the pool Destroying -> return an object to the pool Examples: – Projectiles – Infinitely spawning enemies

Object pool example

Builder Build an object piece by piece instead of all at once – Avoids needing a large number of different constructors A builder object receives each initialization parameter step by step and then returns the resulting constructed object at once Example: Using an EnemyBuilder called enemyBuilder – enemyBuilder.setPosition (10,10); – enemyBuilder.setSprite(Goomba); – enemyBuilder.setAttackSides(left,right,bottom); – …etc… – enemy = enemyBuilder.getResult(); Also can be used in dependency injection

Memento Store the state of an object and allow for restoring the object to that state when needed Originator (example: Level) – Create a memento object representing its current sate – Use a memento object to restore its previous state Memento – Stores internal state of the Originator object. Caretaker (example: Game) – Stores memento objects – Pass originator a memento to revert to an earlier state Revert to previous frame Revert to last checkpoint

Entity component system (main idea) Every GameObject is an Entity – Empty object, usually has a unique id Attach domain behavior to each Entity as a Component – Example domains: position, drawing, collision detection and response, physics, sound Main game loops over domains (MovementManager, SpriteDrawingManager, etc.) instead of over game objects

Entity component system (additional concepts) Not a design pattern, but an alternative programming paradigm (data oriented or driven) Pros: – Can add or remove components easily during runtime – Domains are now separate No class has methods for both drawing and updating Higher cohesion, less coupling Cons: – Can be hard to scale up the number of entities or systems – More complicated abstraction than a typical OOP system

CPU-Memory gap (load less, compute more) Source: papers/taming-the-power-hungry-data-center

Redundancy in an OOP system Image source

Avoiding redundancy with ECS Image source

Additional reading on Entity Component Systems Foundational knowledge – – ides.pdf ides.pdf More recent articles, examples, and guides – based-entity-systems/ based-entity-systems/ – heirachy/ heirachy/ – oriented-programminggcap09 oriented-programminggcap09 – Also has brief but good comments on patterns and anti-patterns