Patterns describe 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 this solution million times over, wihtout ever doing it in the same way twice. Design patters are descriptions of communicating objects and classes that are customized to solve a general problem in a particular context[2].
A design pattern names, abstracts, and identifies the key aspects of a common dessign structure that make it useful for creating a reusable object-oriented design. The design pattern identifies the participating classes and instances, their roles and collaborations, and the distribution of responsiblities. Each design pattern focuses on a particular object-oriented design problem or issue. It describes when it applies, whether it can be applied in view of other design constraints, and the consequences and trade-offs of its use[2].
- State: Main character state management
- Strategy: Level management
- Observer: Collision management
- Singleton: Characters factory-instantiation
- Factory: Characters instantiation
Image 1. Level 1
Image 2. Level 2 (final level)
[1]E. Freeman and E. Robson, Head First design patterns, 1st ed. Sebastopol, CA: O'Reilly, Edition: 10th Anniversary ed., 2014.
[2]E. Gamma, R. Helm and R. Johnson, Design patterns, 2nd ed. Addison Wesley, 1998.