GithubHelp home page GithubHelp logo

augustobecker / so_long Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 1.0 452 KB

A small 2D Game made using the MiniLibX Graphics Library, Textures, sprites and tiles included - @42sp Project

C 95.51% Makefile 4.49%
42cursus ecole42 solong so-long 2d-game mlx

so_long's Introduction

so_long - @42sp

ℹ️ A small 2D Game made using the MiniLibX Graphics Library - Textures, sprites and tiles included.

so_long

123/100 ✅

🪄 Everything small is just a smaller version of something big

Index

What is so_long?

The fifth project at 42 programming school. It's the first graphical project in the 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

⚠️ 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 bonus version:

make bonus

So, run ./so_long followed by the map:

./so_long assets/maps/valid/map2.ber	

For bonus:

./so_long_bonus assets/maps/valid/bonus/map5.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 Coin
E Exit
P Player
0 Floor

For bonus there's an extra character - which makes you lose once touch it.

CHAR OBJECT
T Toxic River

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
Q or Esc Close the game

Use WASD or arrow keys to move.

After getting all the coin bags, the exit opens and you can escape downstairs.

You can close the game by Clicking on the red cross on the window’s frame, or pressing Q or 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 I created my own Tester.

To test the code in this repo Clone this repo and cd into it:

git clone https://github.com/augustobecker/so_long

cd so_long/

Now, clone the Tester

git clone https://github.com/augustobecker/so_long_tester

Go into the test folder and run with make:

cd so_long_tester
make

If you did everything correctly you should see something like this

image

42 Cursus

42 is a global education initiative that proposes a new way of learning technology: no teachers, no classrooms, students learning from their fellow students (peer to peer learning), with a methodology that develops both computing and life skills. Not to mention that it's completely free of charge and open to all with no prerequisites.

Admissions at 42 are unlike other colleges. We use a merit-based admission process. The final step of the admission is the Piscine - This is part of the admissions process and requires 4 weeks of intensive and immersive coding. No prior coding experience is necessary at all.

You can check more about the admission process on the 42sp website: https://www.42sp.org.br or on my github repository: 42 Piscine

To see other projects developed by me at 42, click here: 42 Cursus

Author

Augusto Becker | acesar-l | 🇧🇷👨‍🚀

👋 How to reach me:

so_long's People

Contributors

augustobecker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

izman03

so_long's Issues

Compilation on macOS

NAME = so_long
NAME_BONUS = so_long_bonus

GREEN = \033[0;32m
RED = \033[0;31m
RESET = \033[0m

LIBFT = ./libraries/Libft/libft.a

CC = clang

STANDARD_FLAGS = -Wall -Werror -Wextra
MINILIBX_FLAGS = -L./libraries/mlx -lmlx -lXext -lX11 -I./libraries/mlx

VALGRIND = @Valgrind --leak-check=full --show-leak-kinds=all
--track-origins=yes --quiet --tool=memcheck --keep-debuginfo=yes

REMOVE = rm -f

SRCS_DIR = ./sources/
BONUS_SRCS_DIR = ./bonus_sources/

SRCS = $(addprefix $(SRCS_DIR),
so_long.c
ft_check_map.c
ft_close_game.c
ft_free_memory.c
ft_handle_input.c
ft_init_game.c
ft_init_map.c
ft_render_map.c
ft_utils.c)

SRCS_BONUS = $(addprefix $(BONUS_SRCS_DIR),
so_long_bonus.c
ft_check_map_bonus.c
ft_close_game_bonus.c
ft_free_memory_bonus.c
ft_handle_input_bonus.c
ft_init_game_bonus.c
ft_init_map_bonus.c
ft_render_map_bonus.c
ft_utils_bonus.c)

all: ${LIBFT} ${NAME}

${NAME}:
${CC} ${SRCS} ${LIBFT} ${STANDARD_FLAGS} ${MINILIBX_FLAGS} -o ${NAME}
@echo "$(NAME): $(GREEN)$(NAME) was compiled.$(RESET)"
@echo

bonus: ${LIBFT} ${NAME_BONUS}

${NAME_BONUS}:
${CC} ${SRCS_BONUS} ${LIBFT} ${STANDARD_FLAGS} ${MINILIBX_FLAGS} -o ${NAME_BONUS}
@echo "\n$(NAME): $(GREEN)$(NAME) was compiled with Bonus.$(RESET)"
@echo

${LIBFT}:
@echo
make bonus -C libraries/Libft

clean:
make clean -C libraries/Libft
@echo

fclean:
${REMOVE} ${NAME} ${NAME_BONUS}
@echo "${NAME}: ${RED}${NAME} and ${NAME_BONUS} were deleted${RESET}"
@echo

re: fclean all

rebonus: fclean ${NAME_BONUS}

run: ${NAME}
${VALGRIND} ./${NAME} assets/maps/valid/map4.ber

run_bonus: ${NAME_BONUS}
${VALGRIND} ./${NAME_BONUS} assets/maps/valid/bonus/map5.ber

.PHONY: all clean fclean re rebonus valgrind run run_bonus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.