https://github.com/ekkoz897/42cursus_so_long
One of the first graphical projects at 42 school, so_long introduces us to 2D programming by allowing us to create our first 2D game. Textures, sprites and tiles included.
https://github.com/ekkoz897/42cursus_so_long
2d-game 42-school 42cursus c mlx mlx-library so-long solong sprite-animation
Last synced: 27 days ago
JSON representation
One of the first graphical projects at 42 school, so_long introduces us to 2D programming by allowing us to create our first 2D game. Textures, sprites and tiles included.
- Host: GitHub
- URL: https://github.com/ekkoz897/42cursus_so_long
- Owner: Ekkoz897
- Created: 2023-01-02T12:47:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-21T17:58:30.000Z (about 1 year ago)
- Last Synced: 2025-03-25T21:14:02.209Z (about 1 month ago)
- Topics: 2d-game, 42-school, 42cursus, c, mlx, mlx-library, so-long, solong, sprite-animation
- Language: C
- Homepage:
- Size: 1.16 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
42cursus_So_long
:information_source: A small 2D Game made using the MiniLibX Graphics Library - Textures, sprites and tiles included.
125/100 :white_check_mark:
## Index
* [What is so_long?](#what-is-so_long)
* [Requirements](#requirements)
* [How does it work?](#how-does-it-work)
* [Maps](#maps)
* [Controls](#controls)
* [How do I test it?](#how-do-i-test-it)
* [42 Cursus](#42-cursus)
* [Author](#author)What is so_long?
The fifth project at 42 programming school.
It's the first graphical project in the 42 Cursus, we can choose between 3 options - FdF, Fractol and so_long - that in general
cover different areas, but all 3 are graphical projects. The so_long consists of a top-down game, which we code from scratch using
the MiniLibx graphical library. It involves a series of validations from the map that is passed as argument,
checks to prevent memoy leaks, the game engineering, managing windows, events, sprites and maps.
Requirements
:warning: The project must be written in accordance with the Norm
The Norm is a programming standard that defines a set of rules to follow when writing code at 42. It applies to all C projects within the Common Core by default, and
to any project where it's specified. These are some of them:Each function must be maximum 25 lines, not counting the function's own curly brackets.
Each line must be at most 80 columns wide, comments included.
A function can take 4 named parameters maximum.
You can't declare more than 5 variables per function.
You're not allowed to use: for , do...while , switch , case , goto ,
ternary operators such as `?' and VLAs - Variable Length Arrays.
The norminette (as we call the norm at 42) is in python and open source.
Its repository is available at https://github.com/42School/norminette.
How does it work?
You'll be able to play once you install the MiniLibx features or if you're using one of the machines at 42.
To play, first compile the project with make:
make
In case you wanna play the pre-built maps:make map1; make map2; make map3
So, run ./so_long followed by the map:
./so_long maps/map1.ber
Maps
You can parse any kind of map, as long as it respects the below rules:The map must be a .ber file.
And can only contain these characters:
| CHAR | OBJECT |
| --------- | ---------- |
| 1 | Wall |
| C | Food |
| E | Exit |
| P | Player |
| 0 | Floor |
For bonus there's an extra character - which makes you lose once touch it.
| CHAR | OBJECT |
| --------- | ---------- |
| G | Deadly lake |The map must be rectangular and surrounded by walls '1'.
The map must contain at least one exit, one collectible, and one starting position.
Check some examples in the folder /assets/maps.
As in assets/maps/valid/map2.ber:
![]()
This .ber file generates this map:
![]()
Controls
| KEY | OBJECT |
| --------- | ---------- |
| W or ⬆️ | Move up |
| A or ⬅️ | Move left |
| S or ⬇️ | Move down |
| D or ➡️ | Move para right|
| Esc | Close the game |
Use WASD or arrow keys to move.
You can close the game by Clicking on the red cross on the window’s frame, or pressing Esc.
How do I test it?
To test the game itself it's recommendable to run it with some different maps and try things like:
Running into a wall and see if you're blocked or if the movements counter increase while you're stucked.
Go to the exit withou collecting all the coins.
Go through the same path at least one time.
Try to move with the arrow keys and with WASD.
Check if the window closes when clicking the red cross on window's frame, same with Esc or Q.
Try to minimize the window and open it again.
Run the project with Valgrind to see if there's any memory leak.
To test some map validations as no map, missing argv, multiple argv, invalid extension, map with an empty line, invalid map parameter, missing W parameter, missing C parameter, missing E parameter, missing P parameter, extra P parameter.