Skip to content

๐Ÿ‘พ [42] A 2D graphical game project built using the MiniLibX library, featuring interactive elements and player navigation and implementing event handling, game loop mechanics, and graphical rendering.

Notifications You must be signed in to change notification settings

jack-pepper/so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

79 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฌ so_long

๐Ÿ“ Description

so_long is a 2D game developed as part of the 42 curriculum, utilizing the MinilibX graphical library. The project expands on the standard implementation by incorporating Libxkit, a custom-built library that acts as a small game engine, providing additional tools and abstractions over MinilibX.

The game features multiple levels, each represented with unique assets. The player must collect all collectibles before reaching the exit to progress. To enhance the gameplay experience, the game dynamically changes assets and environment as the player collects a certain percentage of items. The levels included are:

  • Basic Level
  • Ice Level โ„๏ธ
  • Desert Level ๐Ÿœ๏ธ
  • Pac-Man Inspired Level ๐ŸŸก
  • Mario Inspired Level ๐Ÿ„

All sprites used in the game were drawn by myself (badly).

image image image image image

๐Ÿ› ๏ธ Technologies Used

  • C
  • Vim
  • MinilibX (MLX)
  • LIBXKIT (Custom Game Toolkit built on MinilibX)
  • Valgrind (a lot)

๐Ÿ“– Table of Contents

๐Ÿ“ฅ Installation

To set up and run the project locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/pepper/so_long.git
    cd so_long
  2. Compile the project:

    make bonus
  3. Run the game:

    ./so_long maps/valid_map_so_long_bonus.ber

๐Ÿ•น๏ธ Usage

The goal of the game is simple: collect all the collectibles (C) on the map before reaching the exit (E).

๐ŸŽฎ Game Features

๐Ÿž Multiple Themed Levels: The game dynamically swaps textures and sprites to transform the environment.

๐Ÿ–Œ๏ธ Custom Sprites: All graphics were hand-drawn, making the game unique and visually distinct.

๐ŸŽฅ Camera System: The player remains centered while moving through larger maps.

๐Ÿ‘ฟ (Very) Basic Enemy AI: Simple enemy movement and collision detection.

โšก Performance Optimizations: Implemented frame rate control to minimize flickering.

๐Ÿ” Error and Memory Handling: I hope you can find some possible failure scenarios or leaks I may have missed! ๐Ÿ˜…

๐Ÿ–ฅ๏ธ Libxkit - A Custom Game Toolkit

Libxkit is a set of utility functions built on top of MinilibX to simplify and enhance game development:By developing this library, this project goes beyond just using MinilibX โ€” it builds a foundational game framework for future graphical projects.

๐Ÿ”ท ๐ŸŽจ Rendering & Graphics

๐Ÿž Background rendering (render_background)

๐Ÿ› Tile-based map rendering (render_map, rm_put_tiles)

๐Ÿ‘พ Character rendering (render_hero, render_enemy)

๐ŸŽจ Pixel manipulation (mlx_fast_pixel_put)

โœ๏ธ Basic drawing utilities (draw_mlx_line, draw_mlx_circle, draw_mlx_rect)

๐ŸŽฎ ๐Ÿ•น๏ธ Game Mechanics & Interaction

๐ŸŽฅ Camera movement & bounds checking (set_cam, update_cam_pos, center_cam_on_hero)

๐Ÿšถโ€โ™‚๏ธ Character movement & animation (on_motion_up, on_motion_down, move_to_left, move_to_right)

๐Ÿ” Collision detection (check_collision_tile, check_collision_radius)

๐Ÿ–ฅ Game UI rendering (display_steps_on_screen, display_steps_on_terminal)

๐Ÿ—บ๏ธ ๐Ÿ› ๏ธ Map & Level Management

๐Ÿ“œ Map parsing & validation (map_validator, check_border, count_chars)

๐Ÿ”„ Dynamic level loading (load_paths, upload_assets)

๐Ÿ” Flood-fill pathfinding for validation (flood_count, flood_count_left, flood_count_right)

๐Ÿ—๏ธ ๐Ÿ›ก๏ธ Game State & Memory Management

๐ŸŽฌ Game state initialization (init_state, set_state, set_window, set_hooks)

๐Ÿ—‘๏ธ Resource management & cleanup (sl_memfree, sl_destroy_imgs, free_paths)

๐ŸŽญ Dynamic asset loading (load_paths_tiles, load_paths_hero, load_paths_enemy)

๐ŸŽฎ Controls

Key Action
W / โ†‘ Move Up
S / โ†“ Move Down
A / โ† Move Left
D / โ†’ Move Right
ESC Exit the Game

๐Ÿค Contributing

If you'd like to contribute or suggest improvements, feel free to:

  • Fork the repository
  • Create a new branch (git checkout -b feature-branch)
  • Make your changes and commit (git commit -am "Add new feature")
  • Push to your branch (git push origin feature-branch)
  • Open a Pull Request

๐Ÿ’™ Acknowledgments

  • 42 Network for the opportunity to work on this project.
  • The MinilibX creators for providing the core graphical library.
  • Bra1nOut for the idea of a percentage system.

About

๐Ÿ‘พ [42] A 2D graphical game project built using the MiniLibX library, featuring interactive elements and player navigation and implementing event handling, game loop mechanics, and graphical rendering.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published