Skip to content

A graphical project consisting on making a 2D game in C.

Notifications You must be signed in to change notification settings

Nuno-Jesus/42_so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

so_long

This project was graded 125/100.

📒 About

This project is one of the 3 possible graphical projects to develop in Rank 02. You'll learn about rendering, sprites, animations, color schemes and game development in 2D. One of the coolest projects in my opinion!

Mandatory Part

mandatory

player coin space wall exit
Player Collectable Empty Wall Exit

Bonus Part

bonus

player potion enemy enemy2 exit
Player Collectable Enemy Enemy Stage 2 Exit

Extra features

  • Different xpm images for inner and outter walls, depending on the surrounding walls (not covering all cases yet)
  • Enemies start by moving randomly. After collecting every potion, the enemies become angry, turning blue. At this point, they double their moving speed and start chasing the player.
  • More to come...

🚨 Disclaimer

At 42, the C projects are built following a bunch of rules that enforce good coding style. Some of them are:

- No for, do while, switch, case or goto are allowed
- No more than 25 lines per function and 5 functions per file
- No assigns and declarations in the same line (unless static)
- No more than 5 variables in 1 function
... 

🔧 Implementation

Part File Name Functionality
Mandatory get_next_line/ Contains the files from the get_next_line project
includes/ Contains all the necessary .h files
libft/ Contains the files from the libft project
maps/ Contains the map files used to test the project
mlx/ Contains the files of the graphics library to render stuff
srcs/ Contains the files strictly created for this projects (documented in the .h files)
xpm/ Contains the xpm version of the images used to render the game
main.c Where the project is launched from
Bonus map/ Responsible for reading, parsing and assembling the map
move/ Has the logic to move both player and enemies. It also contains the enemies strategies.
render/ Files that handle the rendering process, including animations and choosing the walls images
utils/ Generic and debugging functions
init.c Contains the starting loop function and allocates all necessary memory for the program to work.

📦 Compilation

To compile so_long you should run make in the terminal.

This rule will generate a so_long file, which is the zipped version of all the object files. To launch the executable you should follow this syntax...

$ ./so_long path_to_the_map_file.ber

...where the second argument is the file you should use as input to display the map. Notice that any misconfiguration in the map file won't launch the graphical environment.

If you want to run the bonus, just run make bonus and then, hit the terminal with the following command:

$ ./so_long_bonus path_to_the_map_file.ber

There are bonus dedicated maps in the maps/bonus folder

💫 Testing

This project was tested using self-created map files to test extreme cases.

📞 Contact me

Feel free to ask me any questions through Slack (ncarvalh).