Skip to content

First graphic project at 42, aimed at creating a mini 2D game and familiarizing with the school's graphic library.

Notifications You must be signed in to change notification settings

MathysCogne/42_so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 - SO_LONG

Main GIF

Welcome to So_Long, a 2D game created using MiniLibX for a project at 42 School ! 🌟

Your mission ? Collect all items before finding the exit... but beware of lurking monsters


And Thanks for All the Fish !

Subject

Features


Game Objectives (Mandatory part):

  • 2D View
  • Objective: The player must collect all items on the map and escape via the shortest path.
  • Player Movement: The player can move in four directions (up, down, left, right) and never through walls.
  • Movement Counter in shell

Bonus Features:

  • Random Floor Pattern: Ground textures are randomized, and external walls differ from the labyrinth walls inside the map.
  • Character and Monster Animation: Both the player and monsters are animated during movement.
  • Monsters: Monsters are programmed to pursue the player at all costs. If they encounter a wall blocking their path, they will attempt to find an alternative route to reach the player.
  • Health Management: The player has three lives before dying.
  • Turn-Based Mechanics: The player has as many moves per turn as remaining lives + 1, while monsters always have two moves.
  • User Interface (UI): Displays move counter, item counter, lives remaining, and a turn banner indicating if it’s the player’s or monsters' turn.

Badge So_Long

Key Hooks

Key Description
ESC Quit the game
W or ⬆️ Move up
S or ⬇️ Move down
A or ⬅️ Move left
D or ➡️ Move right

Map Structure (.ber formar)

Each map in .ber format should adhere to specific structural rules:

  • The map is rectangular and closed by walls on all edges.
  • Contains one 'P' (Start) and one 'E' (Exit).
  • Items ('C') must be collectible, with a path allowing the player to reach all items before accessing the Exit.
  • Only the characters shown in the table below are allowed:
Character Description
P Start point
E Exit point
C Item
0 Void / Flat
1 Wall
M Monsters

Project Structure

  • include/

    • Contains header files
  • src/

    • main.c - Entry point of the program
    • so_long.c - Manages core game functions
      • game/ - Contains gameplay logic, including player movement, item collection tracking,monster behavior, and win/loss conditions.
      • map/ - Handles map-related functions, such as loading and validating .ber map files and checking paths for game elements like the exit and items.
      • mlx/ - Manages the interface with the MiniLibX library, including creating windows, rendering textures, and updating the display.
      • utils/ - Utility functions
  • textures/

    • Contains the game's textures, stored in .xpm format
  • map/

    • Directory for .ber maps, including both valid and invalid configurations for testing.
  • librairies

    • MinilibX The graphical library provided by 42
    • Libft A custom implementation of the Libft library with essential functions

Compilation and usage


Dependencies

  • Libft: This project depends on my Libft. Automatically downloaded and installed when you run the make command.

  • MiniLibX: The MiniLibX library will be automatically downloaded and installed when you run the make command. Ensure you have the necessary prerequisites on your machine.


1. To compile, simply run the make command:

This Makefile was generated by my generator available here: MakeMyFile

make

make bonus make clean make fclean make re


2. After compiling, run the game with the following command:

./so_long [path/to/map.ber]

Disclaimer

At 42 School, most projects must comply with the Norm.

About

First graphic project at 42, aimed at creating a mini 2D game and familiarizing with the school's graphic library.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published