Skip to content

A 2D game built in C with MiniLibX for the 42 School curriculum. Collect all items, avoid enemies, and reach the exit. Focuses on graphics rendering, event handling, and map validation, featuring clean architecture, memory safety, and a bonus version with animations and enemies.

Notifications You must be signed in to change notification settings

Felipp3san/42-so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

so_long

A 2D game built in C using MiniLibX, developed as part of the 42 School curriculum.
The goal is to create a small graphical game where a player collects items, avoids enemies (bonus), and reaches the exit.
The project focuses on graphics programming, event handling, and map validation.

Features (Mandatory)

  • 2D map rendering using MiniLibX
  • Player movement with keyboard input
  • Collectibles, walls, and exit tiles
  • Valid path validation for every map
  • Frame rendering and window management
  • Error handling and memory management

Features (Bonus)

  • Enemy movement and collision detection
  • Animations for player, collectibles, and enemies
  • Extra sprites and dynamic elements
  • Improved visual experience

Tech Stack

  • C – Core language
  • MiniLibX – Rendering and event handling
  • Libft – Utility functions
  • Makefile – Build and management

Dependencies

  • GCC 11 – Required compiler

Important

The project will not compile with GCC > 11

  • X11 libraries – For graphics on Linux
  • MiniLibX – Already included in repo
  • Libft – Already included in repo

Installation

  1. Clone the repository:
git clone https://github.com/Felipp3san/42-so_long.git
cd 42-so_long
  1. Compile the project:
make          # Compile mandatory version
make bonus    # Compile bonus version

Usage

Run the game

./so_long maps/maps_with_no_enemies/valid_map.ber
  • The .ber map file defines the layout of the game.
  • The player can move using W, A, S, D.
  • The goal is to collect all items and reach the exit.

Example

./so_long maps/maps_with_no_enemies/valid_map.ber

This loads the map valid_map.ber and starts the game.

Bonus

./so_long_bonus ./maps/maps_with_enemies/map_20x10_enemies.ber

Runs the bonus version with enemies, animations, and additional features.

Map Format

Each map is a .ber file containing:

Symbol Meaning
1 Wall
0 Floor
C Collectible
E Exit
P Player start
X Enemy (bonus)

Example:

111111
1P0C01
1000E1
111111

Compilation

  • Build the mandatory executable:
make
  • Build the bonus executable:
make bonus
  • Remove object files:
make clean
  • Remove all binaries and rebuild:
make re

Project Structure

.
├── include/           # Header files
├── src/               # Source files
│   ├── mandatory/     # Core game source files
│   └── bonus/         # Bonus version source files
├── libft/             # Custom Libft library
├── mlx/               # MiniLibX library
├── build/             # Object files (created after compilation)
└── maps/              # Example map files

License

Educational project under 42 School academic policy.

About

A 2D game built in C with MiniLibX for the 42 School curriculum. Collect all items, avoid enemies, and reach the exit. Focuses on graphics rendering, event handling, and map validation, featuring clean architecture, memory safety, and a bonus version with animations and enemies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published