Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Game Framework Design Riz Verghese Joj.

Similar presentations


Presentation on theme: "Object Oriented Game Framework Design Riz Verghese Joj."— Presentation transcript:

1 Object Oriented Game Framework Design Riz Verghese Joj

2 Frameworks: What are they? Semi complete applications Complete applications can be developed by inheriting from and instantiating parameterized framework components. Provide domain-specific functionality Business, telecom, databases, games. Exhibit inversion of control at run-time Determines which objects and methods to invoke in response to events.

3 Benefits The most profoundly elegant framework will never be reused unless the cost of understanding it and then using its abstractions is lower than the programmers perceived cost of writing then from scratch. - Booch, Dr. Dobbs Journal, 1994.

4 Design Patterns Each pattern describes a problem which occurs over and over again in our environment and then describes the core of the solution to that problem, in such a way that you can use the solution a million times over, without ever doing it the same way twice. - Christopher Alexander, A Pattern Language, 1977.

5 Design Patterns … what are they? A Solution to a problem in context Provide experience reuse instead of code reuse. Hundreds of patterns exists! Vocabulary: Facilitates communication among developers Lets you think at an architecture level, not implementation level. Eg: Factory, Observer, Composite, Singleton

6 Frameworks and Design Patterns

7 An example game framework Classic arcade style games 2D tile based games Basic elementary collision Supports dynamic class loading

8 Another Game

9 The Design Resource Manager Resource Image Resource Sound Resource Sprite Game board Tile Indexer Tile manager Tiles Immovable Tile Movable Tile

10 Patterns Resource Manager Factory Reads from an xml file Dynamic creation of classes Associate images and sounds with a tile Tile Manager Observer Tiles created subscribes to the Tile Manager Tile Manager tells the board where the tiles are Tiles have to request movement from the Tile Manager.

11 Game specific patterns Patterns arent limited to the framework Game specific code can have lots of patterns The Snake game: Especially uses the composite pattern Framework objects mostly follow the singleton pattern where as game specific objects do not.

12 How does the framework work? Resource manager loads the tiles in memory from information in the XML file. Level loader prepares an instance of the board, tiles and placement of the tiles on the board. Game specific class maps input to tile action (usually movement) Tile asks board if it can move to the desired place Board lets tile move or not Property of the tile determine what happens when two tiles occupy the same space Collide, Consume, Cancel.

13 Implementation specifics Two threads The first allows the board to redraw/refresh The second allows every tile to think The think method allows the tiles to Keep moving Keep falling Know what to do on collision Tells other tiles what to do

14 More specifics Tiles can have relations The observer/observable relationship Eg: Acno game: Door disappears when key is eaten Key tells door to disappear Eg: Snake gets longer when apple is eaten Apple tells snake body to spawn

15 Advantages Allows you to step back and generalize More time spent on the framework Isnt worth it for just one game Allows you to spend time on the game (content) not the implementation Saves a LOT of time for one particular game Clean implementation The framework code is generally hidden Game specific code is small (from reusing framework components)

16 Disadvantages Games are limited to the framework Cant build all games Features Limited to framework provision and functionality Sometimes overcome through ugly workarounds/tricks/hacks

17 References The development of a Game Playing Framework using Interface-based programming, Mark Cohen, Issue 12.1, ACM Student Magazine, Fall 2005. Object-oriented Game Development, Julian Gold, ISBN: 032117660X, Addison Wesley, 2004. Introducing Object Oriented Frameworks, Taligent white paper. Designing Reusable Classes, R. Johnson and B. Foote, Journal of Object-Oriented Programming, 1(2):22--35, June/July 1988 Design patterns: Abstraction and reuse of object-oriented design, E. Gamma, R. Helm, R. Johnson, and J. Vlissides, In European Conference on Object-Oriented Programming Proceedings (ECOOP'93), volume 707 of Lecture Notes in Computer Science. Springer-Verlag, July 1993.

18 The end … Discussion


Download ppt "Object Oriented Game Framework Design Riz Verghese Joj."

Similar presentations


Ads by Google