intra to gitea

This commit is contained in:
root
2025-11-15 22:16:13 +00:00
parent 0c0d28ab36
commit 50b45e597f
27 changed files with 888 additions and 624 deletions
+15 -14
View File
@@ -19,7 +19,6 @@ int on_destroy(t_game *g)
textures_free(g);
cleanup_window(g);
world_free(&g->world);
/* Libérer data si disponible */
if (g->data)
{
free_textures(g->data->texture);
@@ -29,15 +28,20 @@ int on_destroy(t_game *g)
return (0);
}
static void set_key(int key, t_game *g, int press)
static void set_key(int key, t_game *g, int press)
{
if (key == KEY_W) g->in.w = press;
if (key == KEY_A) g->in.a = press;
if (key == KEY_S) g->in.s = press;
if (key == KEY_D) g->in.d = press;
if (key == KEY_LEFT) g->in.left = press;
if (key == KEY_RIGHT) g->in.right = press;
if (key == KEY_W)
g->in.w = press;
if (key == KEY_A)
g->in.a = press;
if (key == KEY_S)
g->in.s = press;
if (key == KEY_D)
g->in.d = press;
if (key == KEY_LEFT)
g->in.left = press;
if (key == KEY_RIGHT)
g->in.right = press;
}
int on_keydown(int key, t_game *g)
@@ -56,11 +60,8 @@ int on_keyup(int key, t_game *g)
void setup_hooks(t_game *g)
{
/* croix de fermeture */
mlx_hook(g->gfx.win, 17, 0, on_destroy, g);
/* KeyPress / KeyRelease */
mlx_hook(g->gfx.win, 2, 1L<<0, on_keydown, g);
mlx_hook(g->gfx.win, 3, 1L<<1, on_keyup, g);
/* boucle */
mlx_hook(g->gfx.win, 2, 1L << 0, on_keydown, g);
mlx_hook(g->gfx.win, 3, 1L << 1, on_keyup, g);
mlx_loop_hook(g->gfx.mlx, game_loop, g);
}