jotavare / so_long

Simple 2D game using the minilibx library and C.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linkedin 42

AboutHow to useMandatoryBonusNorminetteLicense

ABOUT

This is a 2D game where the player navigates through a maze-like environment to reach a goal, avoiding obstacles and enemies. It is created using the MiniLibX library and I had to implement game mechanics, file input/output, and basic graphics.

HOW TO USE

1º - Clone the repository

git clone git@github.com:jotavare/so_long.git

2º - Enter the project folder and run make or make bonus

Important: To run the program, you need to download the MiniLibX.

cd so_long/so_long
make or make bonus

3º - Run the game with a map of your choice

./so_long [map.ber]
./so_long_bonus [map_bonus.ber]

MAKEFILE RULES

make - Compile so_long files.

make bonus - Compile so_long_bonus files.

make all - Compile mandatory + bonus files.

make clean - Delete all .o (object files) files.

make fclean - Delete all .o (object files) and .a (executable) files.

make re - Use rules fclean + all.

MANDATORY

  • Must use MiniLibX.
  • Makefile must compile source files and should not relink.
  • The program has to take as a parameter a map description file ending with the .ber extension.

GAME

  • Goal: Collect every collectable and escape choosing the shortest route.
  • W, A, S and D keys must be used to move the main character up, down, left and right.
  • Can't move into walls.
  • Number of movements must be displayed in the shell.
  • Must be a 2D view (top-down or profile).
  • Doesn't need to be real-time.

GRAPHIC MANAGEMENT

  • Display the image in a window and must remain smooth (changing windows, minimizing, ...).
  • Pressing ESC must close the window and cleanly quit the program.
  • Clicking on the window cross must also close and quit the program cleanly.
  • The use of the images of the MiniLibx is mandatory.

MAP COMPONENTS

  • The map should include 3 components to be constructed: walls, collectables and free space.
  • Should be composed of only these 5 characters:
Characters Description
0 Empty space.
1 Wall.
C Collectible.
E Map exit.
P Player starting position.

MAP VALIDATION

  • The map must contain 1 exit, at least 1 collectable, and 1 starting position to be valid.
  • Map must be rectangular.
  • Map must be closed/surrounded by walls. If not, the program should return an error.
  • Check if there is a valid path in the map.
  • The program must be able to parse any kind of map, as long it respects the rules.
  • If an error/misconfiguration is encountered, it should return Error\n followed by an explicit message.

Map .ber example:

111111111111
1001000000C1
100000011101
1P0011E00001
111111111111

BONUS

  • Develop original extra features (optional).
  • Make the player lose when they touch an enemy patrol.
  • Add sprite animation.
  • Display the movement count directly on the screen, instead of writing in the shell.

NORMINETTE

At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.

- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;
- Each function must be a maximum of 25 lines, not counting the function's curly brackets;
- Each line must be at most 80 columns wide, with comments included;
- A function can take 4 named parameters maximum;
- No assigns and declarations in the same line (unless static);
- You can't declare more than 5 variables per function;
- ...
  • 42 Norms - Information about 42 code norms. PDF
  • Norminette - Tool to respect the code norm, made by 42. GitHub
  • 42 Header - 42 header for Vim. GitHub

LICENSE

This work is published under the terms of Unlicense.

About

Simple 2D game using the minilibx library and C.

License:MIT License


Languages

Language:C 96.4%Language:Makefile 3.6%