Skip to content

Repository files navigation

so_long

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.

Full Manual

1. Install requirements

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-dev

Then build MiniLibX from the included minilibx-linux directory if it is not already compiled:

cd minilibx-linux
chmod +x configure
./configure
make

2. Build the game

From the project root, compile everything with:

make

Useful build commands:

make clean

Removes object files.

make fclean

Removes the object files and the executable.

make re

Forces a full rebuild.

3. Run the game

Launch the game by giving it a map file with the .ber extension:

./so_long maps/map.ber

You can also try the other sample maps inside the maps folder.

4. Play the game

  • 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.

How To Make Your Own Map

Anyone can create their own map as long as it follows the rules below.

Required constraints

  • 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.

Valid characters

  • 1 = wall
  • 0 = floor
  • P = player
  • E = exit
  • C = collectible

Map tips

  • 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.

Example map

1111111
1P0C001
1000001
1C00E11
1111111

Project Files

  • 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

Troubleshooting

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages