A project done at Codam University where the goal was to generate a game from a text file using the c-programming language and a small graphics library.
In the game you play as a knight who's goal it is to collect all gold and a key before running to the exit. In the meanwhile, enemies are walking around to prevent you from obtaining your collectables and finishing the game.
Thanks to Leon and Codam for providing the MLX42 graphics library with some handy functions.
Map | Game |
---|---|
111111 1C0001 101001 10E001 1000P1 111111 |
|
111111 1C0001 1GEP01 101111 1G1111 111111 |
Map | Game |
---|---|
11111111111111 1001C000001111 1F00P0000G0001 10000000001001 11010110001F01 10000000001111 100C0000000001 110000000CS001 1000G000001111 1100E000001111 11111111111111 |
Map | Game |
---|---|
... |
The gameplay is generated based on a text file inputted when starting. Some text files for different use cases are already added to the "maps" folder but you are able to create your own according to the following rules:
- The file has to have the .ber file extension
- The map has to be rectangular
- The map can be composed of only these 8 characters:
- 0 for an empty space,
- 1 for a wall,
- C for a collectible,
- E for a map exit,
- P for the player’s starting position.
- G for a goblin enemy
- S for a slime enemy
- F for a flying enemy
- The map must contain 1 exit, at least 1 collectible, and 1 starting position to be valid.
- The map must be closed/surrounded by walls.
- Every collectable (C) and the exit (E) has to be reachable from the players position.
To run the excecutable you can use the following command:
./so_long maps/{name_of_map}
An example using one of the existing maps:
./so_long maps/weirdo.ber