Design patterns in game development
This section will discuss common uses of design patterns in game development. We will explore using some of the patterns from the previous chapter, combined with the introduction of two new patterns (the flyweight pattern and the state pattern).
For this purpose, we’ll implement a hybrid of an action and strategy game, where the player controls a group of agents fighting another group of agents. As part of this game, we will use the following patterns:
- Singleton: The singleton pattern can be used to manage global resources across the game, such as the game manager, the audio system, and the input system.
- Factory pattern: The factory pattern can create different game objects, such as agents, weapons, and ammunition.
- Flyweight pattern: The flyweight pattern can manage game assets, such as terrain, textures, and animation.
- Observer pattern: The observer pattern can be used to monitor player actions and produce the appropriate...