So Long is a fun little 2D maze game where player need to collect all the coins and find the way out to win. No need to worry about creating a map with enemies; the game will automatically add them if there’s enough space, and it’ll still be totally playable.
- Main menu: Player can choose the character (colored: green, red, or yellow):
- Use the arrow keys
←|→orA|Dto pick a color. - Press
Enterto start the game.
- Use the arrow keys
- Win and lose screens.
- Enemies generated automatically: The game adds enemies based on the map with this logic:
- 5% of the free spaces on the map can have enemies (this is for an "easy" difficulty level).
- The game will still make sure it's playable, so if it’s not, no enemies will be placed.
- Enemies are placed randomly on free cells using a pseudo-random number generator (
ft_rand()fromlibf). - Enemies won’t start moving until the player makes their first move, giving some time to figure things out.
- Animation support: Enemies and collectibles have smooth animations, and everything runs at the same speed (FPS is based on speed and the number of frames in the animation).
- Custom map support:
- Map needs to be rectangular, surrounded by walls (
1), and include exactly one player (P) and one exit (E), with at least one collectible (C). - The rest of the map can have
0as free spaces. - The map file needs to have a
.berextension. - The game will check the map and automatically generate the visuals if it’s valid.
- Map needs to be rectangular, surrounded by walls (
- Error handling: If something goes wrong, a clear error message will be shown in
stdout. There are a few types of errors:- Custom errors if there’s something wrong with the map.
- Errors from the
MLX42library if there's a problem on that side. - System errors, like if there’s an issue with memory or reading the file.
| Key | Action |
|---|---|
W or ↑ |
Move Up |
A or ← |
Move Left |
S or ↓ |
Move Down |
D or → |
Move Right |
ESC |
Exit the Game |
Enter |
Start the game (main menu) |
1. Clone the Repository
To clone the repository along with its submodules MLX42 and libft, run:
git clone --recurse-submodules https://github.com/ipersids/2d-maze-game.git so-long
cd so-long2. Build the project:
makeOther commands:
* make clean will remove all .o' files from the directory.
* make fclean will remove all .o' and executable files.
* make re will trigger the fclean command and rebuild the program.
3. Run the game: To run the game with a map, use:
./so_long maps/map.ber4. Enjoy 😎
Made by Julia Persidskaia.
LinkedIn