so_long is a 2D game project for 42Lausanne (42 Network). In this game, the main character (a guy sweeping the floor) must collect all the "42" coins to power on a computer and become a programmer.
In so_long, your objective is to:
- Collect all coins (collectibles) on the map.
- Reach the exit once all coins have been collected.
- Do it in the most efficient way.
The map is provided in .ber extension text file. It must follow these rules:
- Characters used:
0: Empty space1: WallC: Collectible (coin)E: ExitP: Starting position
- The map must be rectangular, completely enclosed by walls, contain exactly one exit, at least one collectible, and one starting position.
- The game also verifies that there is a valid path from the starting position to all collectibles and to the exit.
- Objective: Collect all the coins and then exit the level.
- Movement:
Use WASD keys or arrow keys.WorUp: move upAorLeft: move leftSorDown: move downDorRight: move right
- Each move updates a movement counter printed in the terminal.
- The player cannot move through walls.
The game uses MinilibX for window creation and image rendering. Custom textures are used for the walls, floor, coins, exit, and the main character.
The following programs and services were used for image generation and editing:
- Adobe Stock: Surface textures.
- Ideogram: Item generation.
- GIMP: Image editing.
- ImageMagic: Format conversion.
This project leverages previous 42 work and includes:
- libft
- ft_printf
- get_next_line
The project includes a Makefile that compiles all source files and links the necessary libraries. To compile, simply run:
makeThen, run the game by passing a .ber map file:
./so_long path/to/map.ber- Install dependencies:
sudo apt-get install gcc make xorg libxext-dev libbsd-dev- Clone MinilibX into your project:
git clone https://github.com/42Paris/minilibx-linux.git mlxThe provided Makefile will build MinilibX automatically.
- Add this includes and flags to your Makefile:
# Contains the X11 and MLX header files
INCLUDES = -I/usr/include -Imlx
MLX_FLAGS = -Lmlx -lmlx -L/usr/lib/X11 -lXext -lX11Install XQuartz if needed. Clone MinilibX:
git clone https://github.com/42Paris/minilibx-linux.git mlxUse this includes and flags in your Makefile:
# Contains the X11 and MLX header files
INCLUDES = -I/opt/X11/include -Imlx
MLX_FLAGS = -Lmlx -lmlx -L/usr/X11/lib -lXext -lX11 -framework OpenGL -framework AppKitThis project is for educational purposes as part of the 42 Network curriculum.