diff --git a/includes/main/env.h b/includes/main/env.h index 572b984..1269f7d 100644 --- a/includes/main/env.h +++ b/includes/main/env.h @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/26 15:26:13 by mcolonna #+# #+# */ -/* Updated: 2024/04/20 15:46:49 by mcolonna ### ########.fr */ +/* Updated: 2024/04/20 16:14:20 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,11 +40,12 @@ typedef struct s_env int level_count; int level_current; int level_to_load; - // room + // play t_room room; t_camera camera; int ketchup; int max_ketchup; + bool snas_moved; // moves int moves; } t_env; diff --git a/src/room/object_firsk.c b/src/room/object_firsk.c index 963a914..86a1d43 100644 --- a/src/room/object_firsk.c +++ b/src/room/object_firsk.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/11 13:55:04 by mcolonna #+# #+# */ -/* Updated: 2024/04/18 18:37:10 by mcolonna ### ########.fr */ +/* Updated: 2024/04/20 16:17:08 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,8 @@ static t_direction firsk_brain(t_point pos) { + if (!g_env.snas_moved) + return (NO_DIRECTION); return (pathfinding(pos, room_find(snas_init), true)); } diff --git a/src/room/object_snas.c b/src/room/object_snas.c index 2137010..f013a39 100644 --- a/src/room/object_snas.c +++ b/src/room/object_snas.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/15 15:27:03 by mcolonna #+# #+# */ -/* Updated: 2024/04/19 14:54:49 by mcolonna ### ########.fr */ +/* Updated: 2024/04/20 16:21:05 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,19 +49,16 @@ static t_point snas_loop(t_object *obj, t_point pos) data->tp_spr = sprite_init(SPR_EXIT_TP); } if (data->state == SNAS_STATE_WAITING_TO_WIN) - { - data->wait_before_win--; - if (!data->wait_before_win) - { - win(); - return (point_init(0, 0)); - } - } + if (!--data->wait_before_win) + return (win(), point_init(0, 0)); if (data->state > SNAS_STATE_GOING_TO_EXIT) return (point_init(0, 0)); r = character_loop(&data->character, pos, snas_brain); if (r.x || r.y) + { g_env.moves++; + g_env.snas_moved = true; + } return (r); } diff --git a/src/room/room1.c b/src/room/room1.c index 8bcbbde..423dc35 100644 --- a/src/room/room1.c +++ b/src/room/room1.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/09 15:11:29 by mcolonna #+# #+# */ -/* Updated: 2024/04/20 15:50:09 by mcolonna ### ########.fr */ +/* Updated: 2024/04/20 16:15:11 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -106,6 +106,7 @@ void room_init(t_const_string path) room_fromfile(&g_env.room, path); g_env.ketchup = 0; g_env.max_ketchup = room_count(ketchup_init); + g_env.snas_moved = false; if (room_count(exit_init) != 1) error_str(path, "there must be exactly 1 exit."); if (room_count(ketchup_init) < 1)