Skip to content

Latest commit

Β 

History

History
99 lines (73 loc) Β· 2.87 KB

File metadata and controls

99 lines (73 loc) Β· 2.87 KB

image

πŸ•ΉοΈ So_long

so_long is a 2D graphical game project from the 42 curriculum designed to introduce students to graphics programming using the MiniLibX library. The project involves rendering a map, handling keyboard input, managing sprites, and ensuring game logic.

πŸ“š Table of Contents

πŸ“– Overview

In this project, you create a basic 2D game where a player must navigate a map, collect all items, and exit safely. The map is built from a .ber file and rendered using MiniLibX. The game includes wall collisions, item collection, and win conditions.

✨ Features

  • βœ… Load and validate maps from .ber files
  • βœ… Render walls, floor, collectibles, player, and exit using images
  • βœ… Track number of movements and display them
  • βœ… Handle keyboard input (WASD or arrow keys)
  • βœ… Display win/exit screen when conditions are met
  • βœ… Protect against invalid maps (wrong chars, unclosed walls, unreachable exits, etc.)
  • βœ… BONUS: Animated enemies that patrol or chase the player
  • βœ… BONUS: Player loses the game when colliding with an enemy
  • βœ… BONUS: Added sprite animations and frame updates

βš™οΈ Installation

git clone https://github.com/adil-ech/so_long
cd so_long
make

Ensure you have MiniLibX installed and linked properly.

πŸš€ Usage

./so_long maps/map.ber

Use arrow keys or WASD to move. Your goal is to collect all items and reach the exit.

πŸ“ File Structure

so_long/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.c
β”‚   β”œβ”€β”€ game_loop.c
β”‚   β”œβ”€β”€ render.c
β”‚   β”œβ”€β”€ map_parser.c
β”‚   β”œβ”€β”€ validation.c
β”‚   β”œβ”€β”€ controls.c
β”‚   β”œβ”€β”€ enemy.c            # Bonus
β”‚   β”œβ”€β”€ animation.c        # Bonus
β”œβ”€β”€ include/
β”‚   └── so_long.h
β”œβ”€β”€ maps/
β”‚   └── example.ber
β”œβ”€β”€ img/                   # Contains XPM sprites
β”œβ”€β”€ Makefile

πŸ“„ Subject Breakdown

βœ… Mandatory Part

  • Map parsing and validation
  • Game rendering with MiniLibX
  • Movement tracking and item collection
  • Exit activation logic
  • Input handling and memory management

πŸŽ‰ Bonus Part

  • Implemented enemy behavior and collision detection
  • Basic AI for patrolling or randomly moving enemies
  • Player loses if touched by an enemy
  • Animation system for smooth visual effects
  • Enhanced visuals through sprite cycling

πŸ“¬ License

This project is part of the 42 Network curriculum and should be used as an academic and learning resource.

πŸ“„ Subject PDF

You can read the official 42 So_long subject here:
πŸ‘‰ So_long Subject PDF