diff --git a/dev/TODO.md b/dev/TODO.md index a5bde03..b112721 100644 --- a/dev/TODO.md +++ b/dev/TODO.md @@ -1,5 +1,3 @@ -- Count moves - - Show moves on the screen - Change sprites for top and bottom borders - ESC to quit (what's the point) - Map conditions diff --git a/includes/main/env.h b/includes/main/env.h index 1e86233..4ff91d0 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/08 15:17:26 by mcolonna ### ########.fr */ +/* Updated: 2024/04/08 16:23:27 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,6 +28,7 @@ typedef struct s_env bool input[4]; int ketchup; int max_ketchup; + int moves; } t_env; extern t_env g_env; diff --git a/src/display/display1.c b/src/display/display1.c index d01a761..e877d5a 100644 --- a/src/display/display1.c +++ b/src/display/display1.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/26 15:05:30 by mcolonna #+# #+# */ -/* Updated: 2024/04/02 18:03:21 by mcolonna ### ########.fr */ +/* Updated: 2024/04/08 17:15:15 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,12 @@ void display_erase(void) void display_flush(void) { + const t_memclass mc = mem_subclass(error_err, g_env.mc); + mlx_put_image_to_window(g_env.mlx, g_env.win, g_screenbuf.img, 0, 0); + mlx_string_put(g_env.mlx, g_env.win, 0, 10, 0xFFFFFF, + str_inttostr(error_err, mc, g_env.moves)); + mem_freeall(mc); } void display_destroyall(void) diff --git a/src/main/main.c b/src/main/main.c index 01509b5..be07826 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/26 15:28:34 by mcolonna #+# #+# */ -/* Updated: 2024/04/08 15:16:57 by mcolonna ### ########.fr */ +/* Updated: 2024/04/08 17:18:03 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,7 @@ int loop_hook(void) int main(void) { g_env.max_ketchup = 0; + g_env.moves = 0; g_env.mc = mem_newclass(error_err); g_env.mlx = mlx_init(); if (!g_env.mlx) diff --git a/src/room/object_snas.c b/src/room/object_snas.c index 37af639..06aebc9 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/04 16:08:52 by mcolonna ### ########.fr */ +/* Updated: 2024/04/08 17:11:46 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,8 +27,12 @@ static t_direction snas_brain(void) static t_point snas_loop(t_object *obj, t_point pos) { - return (character_loop( - &((t_snas_data *)obj->data)->character, pos, snas_brain)); + t_point r; + + r = character_loop(&((t_snas_data *)obj->data)->character, pos, snas_brain); + if (r.x || r.y) + g_env.moves++; + return (r); } static void snas_draw(t_object *obj, int x, int y)