feat: firsk is still until snas moves
This commit is contained in:
parent
50fcb82e9e
commit
d88c4c4205
4 changed files with 14 additions and 13 deletions
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue