summaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-05-11 16:27:45 +0200
committerDominik Kaiser2024-05-11 16:27:45 +0200
commite597be4f58e7252333192cb1e4211d74522b6102 (patch)
tree72b1aa0cb9fe4cfdfcff57c312eb80008c31025e /src/draw.c
parentf199b13df1350aa864a9104616f0d9b82606b4ed (diff)
downloadso_long-e597be4f58e7252333192cb1e4211d74522b6102.tar.gz
so_long-e597be4f58e7252333192cb1e4211d74522b6102.zip
Add wall rendering
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/draw.c b/src/draw.c
index de4ba48..b5e5455 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -6,13 +6,41 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 17:58:23 by dkaiser #+# #+# */
-/* Updated: 2024/05/10 11:58:52 by dkaiser ### ########.fr */
+/* Updated: 2024/05/11 16:00:17 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
+#include "MLX42/MLX42.h"
#include "libft.h"
#include "so_long.h"
+int draw_map(t_game *game)
+{
+ int x;
+ int y;
+ mlx_texture_t *wall_texture;
+ mlx_image_t *wall_image;
+
+ wall_texture = mlx_load_png("textures/wall.png");
+ wall_image = mlx_texture_to_image(game->mlx, wall_texture);
+ mlx_resize_image(wall_image, 48, 48);
+ game->map.tile_size.x = 48;
+ game->map.tile_size.y = 48;
+ x = 0;
+ while (x < game->map.grid_size.x)
+ {
+ y = 0;
+ while (y < game->map.grid_size.y)
+ {
+ if (game->map.tiles[y * game->map.grid_size.x + x] == WALL)
+ mlx_image_to_window(game->mlx, wall_image, x * game->map.tile_size.x, y * game->map.tile_size.y);
+ y++;
+ }
+ x++;
+ }
+ return (0);
+}
+
int draw(t_game *game)
{
game->player.img->instances[0].x = game->player.position.x;