This project is a simple 2D game where a player must collect all the items on a map and then reach the exit. The game is built using the mlx library, which is a simple graphics library designed for use in creating 2D games and other visual applications.
External functions: open
, close
, read
, write
, malloc
, free
, exit
, and all functions of the minilibx
.
The player starts at the beginning of the map and must collect all the items before reaching the exit. The player can move up, down, left, and right. The game is won when the player collects all the items and reaches the exit. The game is lost if the player collides with an enemy.
The game supports the following commands:
Command | Description |
---|---|
W or ↑ | Move the player up |
A or ← | Move the player left |
S or ↓ | Move the player down |
D or → | Move the player right |
ESC | Quit the game |
The map is represented by a file with a .ber extension. The map must have a rectangular shape and can only contain the following characters:
Character | Description |
---|---|
1 | Wall |
0 | Floor |
P | Player |
E | Exit |
C | Collectible |
The map must have at one player, one exit, and at least one collectible. All collectibles must be reachable and the map must be surrounded by walls.
Here's an example of a valid map file:
111111111
1P00000C1
10000C001
111111001
100C00001
10C111111
100C00001
1000000E1
111111111
This file will generate the following map:
Before building and running the game, you should first clone this repository and the minilibx
library, which is required to compile the project. You can do this with the following commands:
git clone git@github.com:lucafisc/so_long.git
cd so_long
git clone https://github.com/42Paris/minilibx-linux.git mlx
For Mac, use the following commands instead:
git clone git@github.com:username/so_long.git
cd so_long
git clone https://github.com/42Paris/minilibx-opengl.git mlx
After cloning the minilibx
repository, you will need to run the configure
script to build the minilibx
library:
cd mlx
./configure
cd ..
Now you can compile and run the game. To compile the game, run the following command in the project directory:
make
To start the game, run the following command with a .ber
file as argument:
./so_long maps/map.ber
To clean the compiled files, run the following command:
make clean