This is my solution for the so_long project of the core curriculum of 42 school.
This projects goal is to create your own 2D game where you have a map that can have different dimensions and contents.
Only tested on macOS Catalina (Version 10.15.7).
For all other OS it is not guaranteed to work.
OpenGL and AppKit is required to run it.
If you want to run it on Linux here is a tutorial that might help and here is the required version of miniLibX, this is not tested with my so_long.
A valid map is structured as followed:
- 1 player (
P
) - at least 1 exit (
E
) - at least 1 collectible (
C
)` - is recatangular
- has a solid outside border out of walls (
1
) - all the empty spaces are filled with
0
- map has to be
.ber
- no other characters than:
P
E
C
1
0
- i.e.
map1.ber
: - one new line after the map is valid, if there is anything else, it is not valid
1111111111111
10010000000C1
1000011111001
1P0011E000011
1111111111111
The player can only be moved by WASD
.
The player can not move into walls.
The player can only exit if all collectibles are collected.
The amount of movements is counted and displayed in the terminal.
Every try to move even if it is invalid will be counted as one move.
All the visualization is done with the help of the MiniLibX library.
All of the commands should be run in the root of the directory.
- compile with
make all
- run the game with
./so_long maps/map1.ber
This is how the game looks for the map1.ber.
This is what will be written in the terminal during the game when you successfully win the game.
This is what will be written in the terminal if you give up by closing the game by pressing ESC
or clicking the red cross.