From: Dominik Kaiser Date: Wed, 15 May 2024 15:35:56 +0000 (+0200) Subject: Draw exit X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=71e3dec2a0d675a1d911c529d228814742c49fcf;p=42%2Fso_long.git Draw exit --- diff --git a/include/so_long.h b/include/so_long.h index 5d0d394..b0332d0 100644 --- a/include/so_long.h +++ b/include/so_long.h @@ -6,7 +6,7 @@ /* By: dkaiser player.img->instances[0].x = game->player.position.x; + game->player.img->instances[0].y = game->player.position.y; + return (0); +} + +void draw_exit(t_game *game) +{ + mlx_texture_t *exit_texture; + mlx_image_t *exit_image; + t_vector pos; + + exit_texture = mlx_load_png("textures/exit.png"); + exit_image = mlx_texture_to_image(game->mlx, exit_texture); + mlx_resize_image(exit_image, game->map.tile_size.x, game->map.tile_size.y); + pos = grid_to_screen_pos(game->map.exit_tile, game->map.tile_size); + mlx_image_to_window(game->mlx, exit_image, pos.x, pos.y); +} + int draw_walls(t_game *game) { int x; @@ -41,10 +61,3 @@ int draw_walls(t_game *game) } return (0); } - -int draw(t_game *game) -{ - game->player.img->instances[0].x = game->player.position.x; - game->player.img->instances[0].y = game->player.position.y; - return (0); -} diff --git a/src/init.c b/src/init.c index e7fedf2..7431c26 100644 --- a/src/init.c +++ b/src/init.c @@ -6,7 +6,7 @@ /* By: dkaiser input_direction = ZERO; init_hooks(game); - init_actor(game); + init_player(game); return (0); } @@ -32,7 +32,7 @@ static void init_hooks(t_game *game) mlx_key_hook(game->mlx, on_key_input, game); } -static void init_actor(t_game *game) +static void init_player(t_game *game) { mlx_texture_t *texture; t_actor *player; diff --git a/src/main.c b/src/main.c index 048fa21..fca5cf0 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: dkaiser