summaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-05-15 17:35:56 +0200
committerDominik Kaiser2024-05-15 17:35:56 +0200
commit71e3dec2a0d675a1d911c529d228814742c49fcf (patch)
tree6e53fe40cc25b04aefe9792c261276cea2cbd093 /src/draw.c
parentcb6f98a5fa7bb2ed361abe68b3000f2e3f578ea7 (diff)
downloadso_long-71e3dec2a0d675a1d911c529d228814742c49fcf.tar.gz
so_long-71e3dec2a0d675a1d911c529d228814742c49fcf.zip
Draw exit
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/draw.c b/src/draw.c
index e350ca1..4e7e4e8 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 17:58:23 by dkaiser #+# #+# */
-/* Updated: 2024/05/15 16:41:15 by dkaiser ### ########.fr */
+/* Updated: 2024/05/15 17:31:11 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,26 @@
#include "libft.h"
#include "so_long.h"
+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);
+}
+
+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);
-}