so_long is a small 2D game built with MiniLibX. The goal is to collect every collectible on the map and then reach the exit.
This project is meant to be built on Linux or WSL with MiniLibX available in the project directory.
If you previously got linking errors like cannot find -lmlx, cannot find -lX11, or cannot find -lXext, install the X11 development packages first:
sudo apt-get update
sudo apt-get install -y libx11-dev libxext-devThen build MiniLibX from the included minilibx-linux directory if it is not already compiled:
cd minilibx-linux
chmod +x configure
./configure
makeFrom the project root, compile everything with:
makeUseful build commands:
make cleanRemoves object files.
make fcleanRemoves the object files and the executable.
make reForces a full rebuild.
Launch the game by giving it a map file with the .ber extension:
./so_long maps/map.berYou can also try the other sample maps inside the maps folder.
- Use W, A, S, D or the arrow keys to move.
- Collect every C tile before going to the exit E.
- Walls marked with 1 cannot be crossed.
- Floor marked with 0 is walkable.
- The move counter is printed during the game.
Anyone can create their own map as long as it follows the rules below.
- The map must be rectangular.
- The map must be surrounded by walls.
- The map must contain exactly one player P.
- The map must contain exactly one exit E.
- The map must contain at least one collectible C.
- The map may only use valid characters.
- 1 = wall
- 0 = floor
- P = player
- E = exit
- C = collectible
- Keep every row the same length.
- Make sure the border is fully closed with 1.
- Leave enough open space so the player can reach every collectible and the exit.
- If a map is not reachable, the game will reject it.
1111111
1P0C001
1000001
1C00E11
1111111
- main.c - program entry point
- move.c - player movement
- set_map.c - map loading
- is_valid.c - map validation
- flood_fill.c - path checking
- set_image.c - image loading and drawing
- get_next_line.c and get_next_line_utils.c - file reading
- ft_strlen.c and ft_putnbr.c - utility functions
If the game does not open, make sure:
- You are running it from a Linux environment or WSL with GUI support.
- MiniLibX was successfully built in minilibx-linux.
- The required X11 packages are installed.
- The map file exists and uses the .ber extension.
If the game still fails to compile after installing the dependencies, rerun:
cd minilibx-linux
make clean
make
cd ..
make fclean
make