so_long is a bite-sized 2D game built in pure C using the magical powers of MiniLibX.
Your mission?
🪙 Grab all the cookies, 🏃♂️ avoid enemies, and 🏁 find the exit... before rage quitting.
A classic project from 42 School to get hands-on with event-driven logic, basic rendering, and a touch of retro game dev vibes.
- 🖥️ Window creation & event hooks with MiniLibX
- 🕹️ Smooth keyboard controls (WASD & Arrow Keys)
- 🧩 Validated maps that guarantee a solvable level
- 🎨 Custom textures and pixel-perfect sprites
- 📊 Real-time move counter (for speedrunners, maybe?)
- 🗺️ Support for multiple custom maps via
.berfiles - ❌ Safe and clean game exit (no memory leaks here!)
- ☠️ Enemies to keep you on your toes
- 💥 Animated player sprite (now with extra personality)
- 📟 HUD displaying your moves (because efficiency matters)
- C Language with strict flags:
-Wall -Wextra -Werror - MiniLibX (42’s own graphics library)
- libft and ft_printf (custom-built utilities)
git clone https://github.com/your-username/so_long.git
cd so_long
make./solong <map.ber>Where <map.ber> should look like a secret code made of:
1 = Wall
0 = Floor
C = Collectible
E = Exit
P = Player
(Bonus) A = Enemy
| 🎹 Key | 🏃 Action |
|---|---|
| W | Move up |
| S | Move down |
| A | Move left |
| D | Move right |
| ESC | Exit the game |
src/
├── main.c // The game starts here!
├── init_struct.c // creates and initialize all the structs of the game
├── check_map.c // Parse the map
├── get_map.c // Copy the map into its structure
├── flood_fill.c // checks for a valid path
├── exit_game.c // Cleans up and exits
├── graphics.c // Loads and manage texture
├── move_player.c // Manage player moves
maps/ You can find all the maps here
bonus/
├── bonus_enemy.c // Manage enemy moves
├── bonus_player_animation.c // Manage player animation if all 4 directions
├── bonus_display_moves.c // Display moves on screen
- How to structure a real-time event loop
- Map parsing with 2D arrays
- Memory management when dealing with dynamic inputs
- Basics of 2D rendering with MiniLibX
- That game dev... even simple, can be addicting!
Made with sweat and love as part of the 42 School journey.
skayed - skayed@student.42roma.it
“One more cookie... just one more...”


