Skip to content

mewmewdevart/so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sublime's custom image

so_long

And thanks for all the fish!

GitHub code size in bytes Main language License

💡 About the project

This project is a very small 2D game. Its purpose is to make you work with textures, sprites, and some other very basic gameplay elements (Version: 2.3). This project uses the 42 school's graphical library, MiniLibX.
This project is not meant to be a fully-fledged game, rather an introduction to a minimal, event-wise graphic library, developed over the course.

Mandatory part:

  • Game actions:
    The player can move in four directions but cannot move into walls. To exit the game, the player needs to collect something. The WASD keys are used to move the main character, and the game has a top-down 2D view. The movements are displayed in the shell, and pressing ESC must close the window and quit the program cleanly.
  • Graphics actions:
    The program should display the image within a window, and window management should be smooth, such as switching to another window or minimizing. Pressing the [ESC] key should close the window and quit the program cleanly. The usage of MiniLibX images is mandatory.
  • Map actions:
    The map must be rectangular/square in shape, surrounded by walls with a clear path to the exit. It should be able to parse any type of map as long as it follows the aforementioned rules and contains three components - the exit, player start position, and collectibles. Additionally, if there is a misconfiguration in the map, the program should return an error message to indicate the issue.

Bonus part:

  • Make the player lose when they touch an enemy patrol.
  • Add some sprite animation.
  • Display the movement count directly on screen instead of writing it in the shell.

My implementations:

  • The name displayed in the executable window shows the name of the game and the name of the map that the person chose to open. (I had to remove this, but you can find it in my commit history)
  • Clicking on the cross 'X' on the window's close the game.
  • Press 'R' to reset the game.
  • Cool design border in the map

🧶 Game Rules

The game we choose must follow a set of rules. The executable so_long will receive a map as the only argument, and this map will have a .ber filetype.

The file also must follow these rules:

  • Only P (Character), 1 (wall), 0 (empty), C (collectible), and E (exit) will be accepted characters in our map (except if you add enemies as bonus)
  • The map must be rectangular, i.e. all rows must have the same length
  • There must be at least one exit, one player, and one collectible on the map
  • The map must be closed, i.e. surrounded by walls

If any of these checks fail, the game must end with a error message.

🏆 | The goal is for the player(s) to collect all the collectibles on the map before going to an exit in the least possible number of steps

📁 Structure/

  • include/ The header file of the so_long project.
  • bin/ Where the final executable binary file goes.
  • libs/ The libraries (my own libft + minilibx, which you have to clone).
  • objs/ Keeps all the .o files produced throughout the compilation process.
  • rscs/ All sprites used in the game in .xpm format + some maps (for running and testing the game).
  • srcs/ Where the artcode happens!

🛠️ Usage

Prerequisites

Linux and MacOS This project requires the GNU Compiler Collection, the GNU Make compiler, internet to clone MiniLibX in the libraryfolder and X11 Development Libraries and Headers (sudo apt-get install libx11-dev).

Windows

You'll need to install Xserver in your machine seeing as the library runs on X-Window system. You may also use WSL on Windows 11 and run wsl --update and you should be good to go.
❗️| Make sure you have all the required tools installed on your local machine, then continue with these steps.

Instructions to run the game :

0. Download the archives

# Clone the repository
$ git clone git@github.com:mewmewdevart/so_long.git

# Enter into the directory
$ cd so_long/

1. Run the Game

# Use that command to clone the Minilibx inside the libs/ folder
$ make call_mlx

# Run the command make root directory to run the mandatory part
$ make

# This command compiles the executable file 'so_long' and runs it along with any map
# of your choice (or a custom one) located in the directory 'rscs/maps'.
#	To execute it, run the following command:
$ ./bin/so_long ./rscs/maps/valids/map_valid_rectangle.ber
# If you want to run the bonus part, run the 'make bonus' command in your directory
#	and provide the correct path to the files starting with ./bin/so_long bonus

2. How to play

  • Control the player using the arrow keys (up, down, left, and right) or the letter keys (w, a, s, and d).
  • Press the 'R' key on your keyboard to reset the current level.
  • Press the [ESC] key or Click in the 'X' window to exit the game.

Gameplay Screen

Click here to watch the video

🗺️ Create your own Map:

For curious minds who want to test the project's features:

  • Create a new text file with a .ber extension. This will be your map file.

  • Open the text file in a text editor.

  • Define the map dimensions using this 5 symbols to represent different elements on the map:

    • 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.
  • Create a rectangular or square map, knowing that the map must be surrounded by '1's (walls) and must contain only one 'P' (player's starting point), one 'E' (exit), and multiple 'C's (collectibles). To test all the game features and have a better gaming experience, create a good level design using other game objects such as '0' for empty spaces (where the player can move).

  • After creating the map, you can run it by passing the path of 'bin/so_long' and the path where the map was created:

$ ./bin/so_long map_example.ber

🦾 Technologies

  • VS CODE | I'm a fan of Vim but due to the size of the project, I opted to use Vscode.
  • GNU Compiler Collection | A suite of programming language compilers developed by the GNU Project for C, C++, Objective-C, Fortran, Ada, and other languages
  • GNU Make | A build automation tool for compiling and linking software projects
  • MiniLibX | A simple X-Window System library for graphics programming
  • A classic notebook to take some notes about the project

🔗 References

  • Markdown | Documentation on how to use Markdown.
  • Internet forums and blogs to address my doubts related to the language (Alura, Stack Overflow, and Geeks for Geeks).
  • Google Translate to translate some parts of content that were in another language.
  • 42SP Cadets and others so_longs projects | :)

📜 License

This project is licensed under the terms of the LICENSE file. See the file for more details.

Developed with love 💜 by Larissa Cristina Benedito (Mewmew/Larcrist).

Releases

No releases published

Packages

No packages published