Skip to content

Cartoone9/so_long

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project score

so_long

This is my so_long project, an implementation of a basic 2D game as part of my 42 School coursework. The core of this project revolved around parsing game environments, implementing player interaction, and displaying visuals using MiniLibX. It provided valuable insights into game logic design, collision detection, and the fundamentals of graphical programming with C libraries.

Table of Contents

Usage

First, add the minilibX to the project root and compile it. For Linux users:

git clone https://github.com/42Paris/minilibx-linux.git
cd minilibx-linux && make

After that, to compile the game go to the project root and run:

make
# or
make bonus

Once that's done you can use the program like this:

./so_long map_file.ber

Controls

Move the player:

  • W, A, S, D
  • , , ,

Quit the game:

  • ESC

Examples

The following examples were recorded using the file maps/map_3.ber.
You can find other maps available in the maps/ directory, or add your own.

  • Idle:
    idle-so-long
  • Losing:
    lose-so-long
  • Winning:
    win-so-long

Easter Egg

Pressing E in-game triggers a small hidden animation after winning:
easter-so-long

Note on Project State

All projects from my 42 cursus are preserved in their state immediately following their final evaluation. While they may contain mistakes or stylistic errors, I've chosen not to alter them. This approach provides a clear and authentic timeline of my progress and learning journey as a programmer.

Known Issues & Fix Suggestions

The step counter doesn't update for the final move before winning or losing.
This can be fixed by updating the ft_end_game() function like so:

int	ft_end_game(void *vdata)
{
	t_data  *data;

	data = (t_data *)vdata;
	if (data->end == 0)
		return (ft_game_latency(data));
	if (data->end == 1)
	{
        	// EDIT BEGIN
		if (data->winner + data->loser == 1)
			ft_render_elements(data);
        	// EDIT END

		if (data->loser > 0 && data->loser < 6)
			ft_end_game_loser(data);
		else if (data->winner > 0 && data->winner < 6)
			ft_end_game_winner(data);
		else if (ft_black_fade(data) == 1)
			data->end++;
	}
	if (data->end > 1 && data->end < 30)
		ft_end_game_img(data);
	if (data->end == 30)
		ft_close_window(data);
	return (0);
}

This way the game will update the hud one last time before it ends.

ft_fill_stash() in my get_next_line implementation contains an unprotected malloc() that could cause issues in edge cases.

Credits

Big thanks to BUTTERHANDS who made nearly all the sprites used in this project and released them for free.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors