Skip to content

7orage/42-So_long

Repository files navigation

This project has been created as part of the 42 curriculum by lheteau.
We are the 29th december 2025.

So_long

Previsualisation of the game

Table of contents


  1. Description
  2. Instructions
  3. Ressources

Description


• So_long is a small 2D game developed in C. The goal is to collect all items on a map and reach the exit with the minimum number of movements. This project focuses on graphic management, event handling, and map parsing.


• I used a main structure to wrap all MLX pointers and sub-structures for the player and the map (t_data).


• Unlike the walls or floor which are stored in a char ** (raw map), the collectibles are managed via a Linked List (t_col). This allows for dynamic tracking.
When a player steps on a collectible, it is removed from the list (lst_remove_col) without needing to modify the initial map string constantly. At each move, the game checks if the player's coordinates match any node in the list using lst_verif_col.


• To see the evolution of the list of collectibles, we can implement the following function :

void	lst_display_list(t_col **liste)
{
	int		i;
	t_col	*ptr;

	ptr = *liste;
	i = 0;
	while (ptr != NULL)
	{
		i++;
		ft_printf("Collectible %d, x = %d, y = %d\n", i, ptr->x, ptr->y);
		ptr = ptr->next;
	}
}

Instructions


• To use it in your own project, include the header:
#include "so_long.h".

To compile the project :
make

And to execute it :
./so_long path/to/your/map.ber


• The engine performs the following strict validations before launch:

  • Checks the name, and valid extension (.ber).
  • Ensures the map is rectangular and at least 3x3.
  • Confirms the map is entirely enclosed by walls (1) to prevent the player from leaving the boundaries.
  • Checks for exactly 1 Player, 1 Exit, and at least 1 Collectible.
  • Uses a Flood Fill algorithm to ensure all 'C' and 'E' are reachable.

Ressources


Aurelien Brabant's MiniLibX Guide : A fundamental resource for understanding the initial setup and graphic context.

42 Docs - MiniLibX : A comprehensive deep-dive into advanced MiniLibX features and pixel management.

Introduction to MiniLibX (Video) : A detailed walkthrough of window management, image creation, and the library's core functional principles.


• Artificial Intelligence tools were used to master the optimization of the Makefile.

They were also helpful in the writing and structuring of this README.


• To push the project to its highest standard, the following so_long testers were instrumental in identifying edge cases and validating the robustness of the parsing engine:

gemartin99's So_long-Tester :

augustobecker's so_long-tester :


LinkedIn Gmail - laura.heteauu@gmail.com Previsualisation of the finsih shell message

About

So_long is a small 2D game developed in C as part of the 42 curriculum. The goal is to collect all items on a map and reach the exit with the minimum number of movements. This project focuses on graphic management, event handling, and map parsing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors