feat: count moves
This commit is contained in:
parent
35c3689841
commit
574e012721
5 changed files with 17 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue