Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

flmarsou/so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦊 What is So Long?

So Long is the first graphical project of the 42 Cursus. The objective is to create a simple 2D game where the player navigates a map, collecting items scattered throughout the level to unlock the exit and complete the game.

This project serves as a practical introduction to using external libraries, particularly focusing on graphical rendering, window management, and event handling.

Overview:

  • Parsing:

    Verifies if the arguments are correct.
    Checks the .ber file by checking for valid characters, correct character counts, proper shape, complete enclosure, and valid path, while simultaneously storing information in the struct in the process.

  • Initialization:

    Uses get_next_line to convert the .ber file into an array of string.
    Initializes the MLX library and creates the display window.
    Loads and prepares the init_sprites for rendering.

  • Execution:

    Starts the rendering process to display the walls, floors, collectibles, exit, player tiles, and the in-game text.
    Configures the main game loop to handle user input and game events.

⚒️ Compilation

  1. Run make to compile the program.
  2. Run make re to recompile everything.
  3. Run ./so_long <map_path> to execute the program.

Maps can be found in the maps folder, and has to be in the .ber extension.

Char Entity
1 Wall
0 Floor
P Player
C Collectible
E Exit
H Horizontal Enemy
V Vertical Enemy

Only the specified characters (e.g., walls, floors, etc.).
Maps must be rectangular and enclosed (player cannot move outside the map area).
Maps must contain exactly one player, one exit, and at least one collectible.
It must be possible to reach all collectible(s) and the exit from the starting position.

🧼 Cleaning

  1. Run make clean to remove every object files.
  2. Run make fclean to remove every object files, including the executable.

📑 List of Functions

1. Map

2. Parsing

  • is_valid_char - Checks if the map file contains only correct characters (1, 0, P, C, E).
  • is_valid_count - Checks and counts if there is one player, collectibles, and one exit.
  • is_valid_shape - Checks if the map is rectangular and counts its width and height.
  • is_valid_close - Checks if the map is enclosed with '1' characters on all sides.
  • is_valid_path - Checks if the map is possible (if the player can reach all collectibles and exit) using the Flood Fill algorithm.

3. Display

Walls:

Floors:

Players:

4. Game

X. Utils

About

2D game using the MiniLibX.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published