feat: add activable wall

This commit is contained in:
mcolonna 2024-04-21 16:10:13 +02:00
parent 192f1a866e
commit 840d0b31e9
6 changed files with 68 additions and 5 deletions

View file

@ -12,7 +12,7 @@ CODE = $(addprefix main/, \
visual room1 room2 room3 room_utils1 room_utils2 camera \
pathfinding pathfinding_utils \
object_character object_snas object_wall object_ketchup object_exit \
object_firsk \
object_firsk object_activablewall \
) \
$(addprefix utils/, \
point1 point2 map \

View file

@ -25,6 +25,9 @@ syntax match berF /F/
highlight berB cterm=bold ctermfg=grey
syntax match berB /B/
highlight berA ctermfg=white
syntax match berA /A/
endif
endfunction
autocmd BufReadPost * call BerSyntax()

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 17:47:01 by mcolonna #+# #+# */
/* Updated: 2024/04/18 18:17:16 by mcolonna ### ########.fr */
/* Updated: 2024/04/21 16:06:33 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -55,6 +55,8 @@ typedef struct s_exit_data
bool active;
} t_exit_data;
t_object exit_init(t_memclass mc);
// FIRSK
typedef struct s_firsk_data
{
@ -63,6 +65,12 @@ typedef struct s_firsk_data
t_object firsk_init(t_memclass mc);
t_object exit_init(t_memclass mc);
// ACTIVABLE WALL
typedef struct s_activablewall_data
{
t_sprite spr;
} t_activablewall_data;
t_object activablewall_init(t_memclass mc);
#endif

View file

@ -3,7 +3,7 @@
100000010101
100000010101
100000010101
100000010101
10000001A101
100000010101
100000010101
100000010101

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/26 16:32:36 by mcolonna #+# #+# */
/* Updated: 2024/04/20 15:47:12 by mcolonna ### ########.fr */
/* Updated: 2024/04/21 16:04:08 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,6 +23,7 @@ const t_consts g_consts = {
{c: 'E', object: exit_init, surface: CASE_FLOOR_1},
{c: 'F', object: firsk_init, surface: CASE_FLOOR_1},
{c: 'B', object: NULL, surface: CASE_BRIDGE},
{c: 'A', object: activablewall_init, surface: CASE_FLOOR_1},
{c: '\0'}
},
levels: {

View file

@ -0,0 +1,51 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* object_activablewall.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 15:27:03 by mcolonna #+# #+# */
/* Updated: 2024/04/21 16:09:40 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes.h"
static t_point activablewall_loop(t_object *obj, t_point pos)
{
(void)obj;
(void)pos;
return (point_init(0, 0));
}
static void activablewall_draw(t_object *obj, t_point p)
{
if (g_env.ketchup < g_env.max_ketchup)
sprite_draw(p, &((t_activablewall_data *)obj->data)->spr);
}
static bool activablewall_walk_through(
t_object *obj, t_character *character, t_point pos)
{
(void)obj;
(void)character;
(void)pos;
return (g_env.ketchup == g_env.max_ketchup);
}
t_object activablewall_init(t_memclass mc)
{
static const t_objecttype type
= {solid_firsk: false, solid_snas: false,
init: activablewall_init, loop: activablewall_loop,
draw: activablewall_draw, walk_through: activablewall_walk_through};
t_object r;
t_wall_data *data;
r.type = type;
data = mem_alloc(error_err, mc, sizeof(t_activablewall_data));
data->spr = sprite_init(SPR_WALL);
r.data = data;
return (r);
}