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).
- C
- Vim
- MinilibX (MLX)
- LIBXKIT (Custom Game Toolkit built on MinilibX)
- Valgrind (a lot)
- Installation
- Usage
- Game Features
- Libxkit - A Custom Game Toolkit
- Controls
- Contributing
- Acknowledgments
To set up and run the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/pepper/so_long.git cd so_long
-
Compile the project:
make bonus
-
Run the game:
./so_long maps/valid_map_so_long_bonus.ber
The goal of the game is simple: collect all the collectibles (C
) on the map before reaching the exit (E
).
๐ 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 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.
๐ 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)
๐ฅ 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 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 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)
Key | Action |
---|---|
W / โ |
Move Up |
S / โ |
Move Down |
A / โ |
Move Left |
D / โ |
Move Right |
ESC |
Exit the Game |
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
- 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.