Small game with focus on using Design Patterns.
Your main goal in this game is to cross the road as a small chicken. Watch out, as some vehicle behavior can be unpredictable. After successfully crossing the street, you are moved to the next, randomly generated level with restored health points.
For controling your character use arrows (<- and ->) or change controls in Settings Menu. Use arrows and enter to navigate through menus and q to quit to the main menu/quit the game.
The purpose of creating this game was purely educational. I tried to use a lot of design patterns and follow object-oriented design principles, even if some of them weren't necessary in this small project.
I used LibGDX library.
Pixel art by me.
- State - altering between game screens, such as Main Menu, Settings etc. In the Game class, methods such as
render()
,dispose()
,resize()
delegate state-related work to current game screen. - Singleton - ensuring only one instance of Player class and providing global access to it.
- Template method - skeleton of algorithm in
render()
method - used in abstract class GameScreenState, subclasses override some steps. - Composite - composing drawable objects (graphics) into tree structure, all of them are implementing same interface, so we can call
draw()
andupdate()
methods on whole tree. - Prototype - used in spawning Vehicles on Road, radomly producing clones of generic prototypes in prototype registry (VehicleRegitry class, Vehicle has
clone()
method). - Command - encapsulating commands, such as moving Player, allowing to easily change some controls in settings.
- Decorator - attaching new behavior to DrawableCommand in CommandDecorator class. Used in implementing drawable menu buttons.
- Adapter - used in CommandAdapter. Decided to use Adapter instead of time-consuming rewriting some parts of Command related code.
- Strategy - family of interchangeable driving algorithms for Vehicle objects.
- Observer - Road (Observable) is notyfing Vehicles (Observer) about certain evens, allowing Vehicles to change their behavior.
- Flyweight - all instances of MovingSnowflake class share common parts as reference to the model object of Snowflake.
- (Null Object - used in NullCommand - calling
execute()
that will do nothing, instead of checking if command is null)