feat: loots of things!!! *

Added features:
- Check if the room is valid
- Pathfinding
- Firsk
- Camera
Changes:
- Borders
Dev:
- new test rooms
- ber.vim plugin
This commit is contained in:
mcolonna 2024-04-15 19:23:58 +02:00
parent b7a2d0494f
commit 9e81a59a7e
95 changed files with 8342 additions and 147 deletions

25
includes/room/camera.h Normal file
View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* camera.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/11 16:31:42 by mcolonna #+# #+# */
/* Updated: 2024/04/11 17:56:43 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CAMERA_H
# define CAMERA_H
# include "includes.h"
typedef struct s_camera
{
t_point pos;
} t_camera;
void camera_sync(void);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 17:46:05 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:46:46 by mcolonna ### ########.fr */
/* Updated: 2024/04/15 17:58:02 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,12 +27,13 @@ typedef struct s_character
t_direction direction;
t_sprite spr;
int walk_remaining_steps;
int walk_steps_nb;
t_character_sprites *sprites;
} t_character;
void character_draw(t_character *character, int x, int y);
void character_draw(t_character *character, t_point p);
t_point character_loop(t_character *character, t_point pos,
t_direction (*brain)(void));
t_character character_init(t_character_sprites *sprites);
t_direction (*brain)(t_point));
t_character character_init(t_character_sprites *sprites, int walk_steps_nb);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 14:58:25 by mcolonna #+# #+# */
/* Updated: 2024/04/09 14:34:13 by mcolonna ### ########.fr */
/* Updated: 2024/04/15 17:42:06 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,8 +21,9 @@ typedef t_object (*t_object_init)(t_memclass);
typedef struct s_objecttype
{
t_object_init init;
bool solid;
t_point (*loop)(t_object *, t_point pos);
void (*draw)(t_object *, int x, int y);
void (*draw)(t_object *, t_point p);
// Called when a character want to walk through this object.
// Returns false to block the character. If true, it will pass.
// If walk_through is NULL, the character is blocked.

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 17:47:01 by mcolonna #+# #+# */
/* Updated: 2024/04/08 15:22:05 by mcolonna ### ########.fr */
/* Updated: 2024/04/11 13:54:23 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -44,6 +44,14 @@ typedef struct s_exit_data
bool active;
} t_exit_data;
// FIRSK
typedef struct s_firsk_data
{
t_character character;
} t_firsk_data;
t_object firsk_init(t_memclass mc);
t_object exit_init(t_memclass mc);
#endif

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pathfinding.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/10 18:13:05 by mcolonna #+# #+# */
/* Updated: 2024/04/12 17:50:50 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PATHFINDING_H
# define PATHFINDING_H
# include "includes.h"
t_direction pathfinding(t_point start, t_point finish);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 23:00:45 by mcolonna #+# #+# */
/* Updated: 2024/04/09 14:22:51 by mcolonna ### ########.fr */
/* Updated: 2024/04/15 17:50:29 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,4 +37,6 @@ t_object *room_getobjectfaced(
bool room_canwalk(
t_room room, t_character *character, t_point pos);
t_point room_find(t_object_init objtype);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/03 15:34:18 by mcolonna #+# #+# */
/* Updated: 2024/04/03 15:51:14 by mcolonna ### ########.fr */
/* Updated: 2024/04/11 17:07:59 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@ typedef struct s_visual
t_sprite spr;
} t_visual;
void visual_loop(t_visual **visual, int x, int y);
void visual_loop(t_visual **visual, t_point p);
void visual_addtoroom(t_spritesmap_id sprid, t_point pos);
#endif