Welcome to the so_long
project! 🚀 This is a 2D maze game project from 42 School where you navigate through a maze, collect items, and reach the exit. This project uses the mlx42
library for handling graphics and user input.
so_long
is a simple 2D game where the goal is to navigate through a maze, collect items, and reach the exit. The game is rendered using the mlx42
library, and the maze is designed using a map file with a specific format.
- Maze Navigation: Move through the maze using keyboard controls.
- Item Collection: Collect items scattered throughout the maze.
- Exit: Reach the exit to complete the level.
- Graphics: Rendered using
mlx42
for a graphical interface.
-
Clone the Repository:
git clone https://github.com/yourusername/so_long.git cd so_long
-
Install
mlx42
:- Follow the mlx42 installation guide to set up
mlx42
. You may need to install some dependencies as well.
- Follow the mlx42 installation guide to set up
-
Compile the Code:
make all
-
Run the Game:
./so_long map.ber
Replace
map.ber
with the path to your map file. -
Controls:
- W - Move Up
- A - Move Left
- S - Move Down
- D - Move Right
- ESC - Exit the game
The game uses a map file with the .ber
extension. The map file format must follow these rules:
-
Characters:
1
- Wall0
- Empty spaceP
- Player starting positionE
- ExitC
- Collectible item
-
Map Constraints:
- The map must be surrounded by walls (
1
). - The map must contain exactly one player (
P
), one exit (E
), and at least one collectible (C
).
- The map must be surrounded by walls (
Here is an example of a valid map file:
111111
1P0C01
1C0C01
1E00001
111111