Skip to content

Build a 2D game with the MinilibX library, where players navigate a map, collect items, and avoid obstacles, while learning game mechanics, graphics rendering, and event handling.

Notifications You must be signed in to change notification settings

lai-jia-jing/so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

so_long

The So_Long project is a 2D game created in C, as part of the 42 coding curriculum. Using the MiniLibX graphics library, the game involves navigating a player through a grid-based map filled with walls, collectibles, and an exit. The player moves by responding to keyboard inputs, collecting items, and reaching the exit to win. The project emphasizes map parsing, event handling, memory management, and basic game mechanics, offering a hands-on way to practice these concepts in a simple graphical environment.

Final score

125%

Usage

You will be able to play the game once you have installed the MiniLibX library on your system. Alternatively, if you're using one of the computers provided at 42, the library should already be installed, allowing you to run the game without any additional setup.

How to compile:

make

make bonus

Run ./so_long followed by the path of map:

./so_long maps/mandatory2.ber

./so_long_bonus maps/bonus3.ber

Map must adhere to the following rules:

Rectangular Shape: The map must be rectangular, meaning all rows must have the same length.

Valid Characters: The map must only contain specific characters:

Character Represent
1 Wall
C Collectable
E Exit
P Player
0 Empty space
P Enemy patrol

Walls Around the Map: The outer boundary of the map must be made entirely of walls ('1'). There should be no open spaces ('0') or other characters at the map's edges.

At Least One Player ('P'): The map must contain exactly one starting position for the player ('P').

At Least One Collectible ('C'): The map must have at least one collectible item ('C') for the player to collect.

At Least One Exit ('E'): The map must contain at least one exit ('E'), which the player must reach after collecting all collectibles.

No Isolated Spaces: There should be no isolated spaces where the player cannot reach the exit or collectibles. All areas should be accessible from the starting point.

Key Function
W Move up ⬆️
A Move left ⬅️
S Move down ⬇️
D Move right ➡️
Esc Quit the game

Use the WASD keys to move.

Once you’ve collected all the collectables, the exit will open, allowing you to escape.

You can close the game by clicking the red cross on the window’s frame, or by pressing Esc.


About

Build a 2D game with the MinilibX library, where players navigate a map, collect items, and avoid obstacles, while learning game mechanics, graphics rendering, and event handling.

Topics

Resources

Stars

Watchers

Forks