So_long is a 2D puzzle game developed as part of the 42 School curriculum. In this game, you control a character navigating through a maze to collect items and reach an exit. The unique twist: every tile you walk on becomes a wall, making your path choices permanent and strategic.
This mechanic transforms a simple collection game into a challenging puzzle where planning ahead is essential. You'll need to carefully consider each move to ensure you can collect all items and reach the exit without getting trapped.
- Unique Movement Mechanic: Each tile you step on transforms into a wall, making backtracking impossible
- Path Validation: All maps are validated to ensure they have a solution
- Reset Function: Press 'R' to restart the level when you get stuck
- Collectibles: Gather all items before reaching the exit
- W / Up Arrow: Move up
- A / Left Arrow: Move left
- S / Down Arrow: Move down
- D / Right Arrow: Move right
- R: Restart the current level
- ESC: Exit the game
0: Empty space (floor)1: WallP: Player starting positionC: CollectibleE: Exit
- GCC compiler
- Make
- X11 development libraries
-
Clone the repository:
git clone https://github.com/TiagoVR4/so_long.git cd so_long -
Compile the game:
make
./so_long maps/[map_file].berMaps are stored in .ber files with the following rules:
- Maps must be rectangular
- Maps must be enclosed by walls (
1) - Maps must contain exactly one player (
P), at least one collectible (C), and at least one exit (E) - Every collectible must be reachable
- There must be a valid path to the exit
1111111111111
1P000000000C1
1000111111001
10001C0000001
1000111111001
10000000C0001
1000111111001
1C00000000E01
1111111111111
/src: Source code files/maps: Map files in .ber format/img: Game sprites/libft: Custom C library/minilibx-linux: Graphics library
This game implements a unique variant of path-finding puzzles known as "self-avoiding walk puzzles" or "one-way path puzzles." The player's challenge is to find a specific path that allows collecting all items without creating a situation where essential parts of the map become unreachable.
- MiniLibX Graphics Library: Used for window management and rendering
- Path Validation Algorithm: Implements a recursive depth-first search to verify map solvability
- Dynamic Memory Management: Careful handling of allocated resources to prevent memory leaks
- Error Handling: Robust validation for maps and game states
The core game logic revolves around the concept of each step creating a wall behind you. This transforms the gameplay from a simple collection task to a complex puzzle where every move must be planned carefully.
This project was created as part of the curriculum at 42 School.