1 / 5

Additional Design Patterns for Games

Additional Design Patterns for Games. For CSE 3902 Matt Boggus. Memento. Store the state of an object and allow for restoring the object to that state when needed Originator (example: Level) Can create a memento object representing its current sate

hal
Download Presentation

Additional Design Patterns for Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Additional Design Patterns for Games For CSE 3902 Matt Boggus

  2. Memento • Store the state of an object and allow for restoring the object to that state when needed • Originator (example: Level) • Can create a memento object representing its current sate • Can use a memento object to restore its previous state • Memento • Stores internal state of the Originator object. • Caretaker (example: Game) • Responsible for keeping the memento • Caretaker does not operate on it, only stores it • With an array list of Level mementos we can revert back to an earlier time

  3. Observer • Mainly used to implement event handling • Subject maintains a list of its dependents (called observers) and notifies them of state changes

  4. 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();

  5. Flyweight • An object that minimizes memory use by sharing as much data as possible with other similar objects • Examples • Projectiles • Enemies

More Related