Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

so_long

so_long is a simple 2D top-down game built with the MLX42 graphical library, as part of the 42 core curriculum. The game involves parsing and rendering a map, handling player movement, collecting items, and reaching an exit — all while ensuring proper memory management and error handling. Gameplay animation

Features

  • Map parsing from .ber files with full validation
  • Real-time keyboard controls
  • 2D rendering using textures via MLX42
  • Win condition tracking and step counter
  • Flood-fill algorithm for accessibility validation
  • Graceful error handling and memory cleanup
  • Dynamic texture loading and player tracking

Game Rules

  • The player (P) must collect all collectables (C)
  • Then reach the exit (E) to win
  • Walls (1) are impassable
  • Empty spaces (0) are walkable
  • Game ends with a win or window close

Map Format (.ber)

A valid map file must:

  • Be rectangular
  • Be enclosed by walls
  • Contain 1 player, 1 exit, and at least 1 collectable
  • Only use characters: 01PCE Example: 111111 1P0C01 100001 1C0E11 111111

Build & Run

  1. Navigate to the project directory:
git clone https://github.com/Yuxin29/Solong.git Solong
cd Solong
  1. Compile using the provided Makefile:
make            # Generate the executable so_long
  1. Other make commands:
make clean     # Remove object files
make fclean    # Remove object files and executable
make re        # Recompile everything from scratch
  1. Running the Game Run the game with a valid .ber map:
./so_long path/to/map.ber

About

A 2D game in C using MLX, where the player collects items and reaches an exit. Implements game logic, map parsing, and event handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages