https://github.com/mathyscogne/42_so_long
First graphic project at 42, aimed at creating a mini 2D game and familiarizing with the school's graphic library.
https://github.com/mathyscogne/42_so_long
2d-game 42 c solong
Last synced: 7 months ago
JSON representation
First graphic project at 42, aimed at creating a mini 2D game and familiarizing with the school's graphic library.
- Host: GitHub
- URL: https://github.com/mathyscogne/42_so_long
- Owner: MathysCogne
- Created: 2024-10-25T21:05:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-26T13:28:55.000Z (over 1 year ago)
- Last Synced: 2024-12-20T04:17:33.234Z (over 1 year ago)
- Topics: 2d-game, 42, c, solong
- Language: C
- Homepage:
- Size: 19.7 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
42 - SO_LONG
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 !
## 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.
### 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`](./src/main.c) - Entry point of the program
- [`so_long.c`](./src/so_long.c) - Manages core game functions
- [`game/`](./src/game/) - Contains gameplay logic, including player movement, item collection tracking,monster behavior, and win/loss conditions.
- [`map/`](./src/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/`](./src/mlx/) - Manages the interface with the MiniLibX library, including creating windows, rendering textures, and updating the display.
- [`utils/`](./src/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`](https://harm-smits.github.io/42docs/libs/minilibx) The graphical library provided by 42
- [`Libft`](https://github.com/MathysCogne/MyLibft_GNL_Printf) 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`](https://harm-smits.github.io/42docs/libs/minilibx/getting_started.html) on your machine.
**1.** To compile, simply run the `make` command:
*This Makefile was generated by my generator available here: [`MakeMyFile`](https://github.com/MathysCogne/Make_My_File-42)*
```bash
make
```
``make bonus``
``make clean``
``make fclean``
``make re``
**2.** After compiling, run the game with the following command:
```bash
./so_long [path/to/map.ber]
```
## Disclaimer
> At 42 School, most projects must comply with the [Norm](https://github.com/42School/norminette/blob/master/pdf/en.norm.pdf).