A Mario-inspired side-scrolling platformer game built using SDL2 and C++.
- Classic Mario-style side-scrolling gameplay
- Coin collection system
- Obstacle avoidance
- Health system
- Background music and sound effects
- Continuous scrolling parallax background
- Score tracking system
- P - Start the game
- ← - Move left
- → - Move right
- ↑ - Jump
- Q - Quit game (after game over)
- R - Restart game (after game over)
To run this game, you need:
- MinGW-w64 with g++ compiler
- SDL2 development libraries:
- SDL2
- SDL2_image
- SDL2_mixer
- Make sure you have MinGW-w64 installed and added to your system PATH
- Download this folder (SDL2 library files in
lib/andinclude/directories) - Ensure all SDL2 DLL files are in the same directory as the executable.
- Open PowerShell in the project directory
- Build the game:
mingw32-make- Run the game:
.\Game.exe- Open the project in Visual Studio Code
- Use the built-in build task (Ctrl+Shift+B) or run:
g++ *.cpp -I"./include/SDL2" -L"./lib" -w -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -o Game.exe- Run the generated
Game.exe
- Open PowerShell in the project directory
- Run the following command:
g++ *.cpp -I"./include/SDL2" -L"./lib" -w -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -o Game.exe- Execute the game:
.\Game.exeGame.cpp/hpp- Main game logic and initializationMario.hpp- Player character implementationObstacle.hpp/ObstacleGenerator.hpp- Obstacle systemCoin.hpp/CoinGenerator.hpp- Coin collection systemPlayerStates.hpp- Player state managementUtility.hpp- Utility functions for texture loadingTimer.hpp- Game timing management
If you encounter any issues:
- Ensure all SDL2 DLLs are in the same directory as the executable
- Verify that the
ImagesandMusicfolders contain all required assets - Check that the SDL2 development libraries are properly installed and linked
- Make sure you're using the correct version of MinGW-w64 (64-bit)