Build a very small 2D game
so_long
is a 2D game project developed as part of the Hive Helsinki curriculum. The goal of this project is to create a simple game using the MLX42 library, a simple window management and graphics library.
In the game, the player collects collectibles in a map and reach the exit. The map is a grid, and the player can only move one square at a time. The game counts the number of moves the player makes.
This project was completed as a solo project. It provided an opportunity to learn about graphics programming, game logic, and working with external libraries in C.
- No bonuses were implemented in this project.
The assets used in this project were taken from:
- Simplified Platformer Pack: Link to Asset
- The
Makefile
in this project uses the-framework Cocoa -framework OpenGL -framework IOKit
flags, which are specific to macOS. If you're using a different operating system, you might need to modify theMakefile
to use the appropriate flags for your system. gcc
orclang
make
MLX42
library. You can find it herelibft
library.
- Use
W
or↑
to move up,A
or←
to move left,S
or↓
to move down, andD
or→
to move right. - Collect all the collectibles in the map.
- Reach the exit once all collectibles have been collected.
- Clone the repository:
git clone https://github.com/lkilpela/so_long.git
- Navigate into the project directory:
cd so_long
- Compile the project:
make
- Run the game:
./so_long map_file/map1.ber
The game map is a .ber
file with the following format:
1
represents a wall.0
represents an empty space.C
represents a collectible.E
represents the exit.P
represents the player.
Here are some conditions that can make a map format invalid:
- The map is not surrounded by walls (represented by '1').
- The map contains characters other than the predefined ones (for example, 'P', 'E', 'C', '0', '1').
- The map does not contain a player ('P') or exit point ('E').
- The map contains more than one player or exit point.
- The map contains empty line.
- The map does not have valid path.
- The map does not have .ber extension
The so_long
project was evaluated based on the following criteria:
-
Game Logic: The game must correctly implement the required logic, including player movement, collectible gathering, and exiting the game.
-
Graphics: The game must use the MiniLibX library or MLX42 to create a graphical interface.
-
Performance: The game must run smoothly without any performance issues or memory leaks.
-
Code Quality: The code must be clear, concise, and efficient. It should be well-organized and easy to read.
-
Compiling: The project must compile without any errors or warnings.
Here are some of the comments received during the peer evaluation of the so_long
project:
Peer 1: "The project looks good and I like the choice of graphics. Lumi was able to explain how the code works, and I tested the functionality and edge cases according to the eval form. There are some discrepancies between the subject document and the eval form, for example subject wants Error being followed by a newline before the error message, but the eval form does not require it. Also according to the eval form the exit should only work after all collectibles have been collected, but it doesn't state that in the subject. Therefore I judged that it's up to interpretation and either choice can be defended. Good luck in the next evaluations!"
Peer 2: "Lumi's so long was a great learning experience! She was able to explain her code and it was structured in a very easy to follow way. It's great for me to see a fully functional version since I'm working on this project myself and she even helped clarify some misconceptions that I had about the mlx library. I tried to break it but it passed every one of my tests. Overall a great job! There was a small point regarding being able to exit without obtaining all the collectibles but it was not specified clearly in the subject. She was able to defend her logic successfully and even though you can exit without all the collectibles it is a pass in my book after scanning through the subject looking for something that said otherwise. Really visually appealing project and the game runs smoothly. Thanks for taking the time to explain it to me and good luck with the next evals!"
Peer 3: "Lumi's project was very cleanly written and she did a great job explaining it. She had very diverse test maps and test cases prepared for the evaluation. The program also passed any test I could come up with to test it and even in those cases had no leaks. Great job!"
This project is licensed under the MIT License - see the LICENSE file for details.