This is a basic implementation of the classic Mario game using C++ and OpenCV,
with design patterns such as Observable, Factory, Entities Pool, and Animation Graphics.
It also has physics implemented so that Mario can run right, run left, jump, and duck.
OpenCV (version 4.5.2 or later)
download OpenCV
and place them under OpenCV_451/bin folder
C++11 or later
Clone the repository
Make sure you have OpenCV installed
Build the project using a C++ compiler
Run the executable file
Use the following keys to control Mario:
'w' key : jump
's' key: duck
'a' key : move left
'd' key: move right
Collect coins and power-ups while avoiding enemies
Design Patterns Used
The Observable pattern is used to notify the game engine of events such as collisions and user input.
Classes such as Mario and Enemy inherit from the Observable class, which contains methods for registering and notifying observers.
The Factory pattern is used to create game entities such as Mario, Enemy, and PowerUp.
The EntityFactory class is responsible for creating these entities based on user input and game events.
The Entities Pool pattern is used to reuse game entities such as Enemy and PowerUp to minimize memory allocation and deallocation.
The EntitiesPool class manages a pool of entities that can be reused when they are no longer needed.
#Animation Graphics
Animation Graphics are used to create the animations of characters and objects in the game.
The Animation class is responsible for loading and animating sprites for game entities.
Physics
Physics are implemented using a basic kinematic model to simulate the movement of objects in the game.
The Physics class contains methods for handling collisions, gravity, and movement.
Contributions to this project are welcome. Please fork the repository and submit a pull request for review.
This project is licensed under the MIT License. See the LICENSE file for more information.