diff options
| author | Dominik Kaiser | 2024-05-11 16:46:09 +0200 |
|---|---|---|
| committer | GitHub | 2024-05-11 16:46:09 +0200 |
| commit | 7b021c4426f21bf20fed61459ddedb5224e25bc4 (patch) | |
| tree | 7115ef51d858fe2275c7402a46716f66906fb2f4 /src/draw.c | |
| parent | 18c61f3119e468e9a9418aef8aaeadcef090895c (diff) | |
| parent | 796108c1ebe5085da626ab82e5866ce5ec1383c2 (diff) | |
| download | so_long-7b021c4426f21bf20fed61459ddedb5224e25bc4.tar.gz so_long-7b021c4426f21bf20fed61459ddedb5224e25bc4.zip | |
Merge map-input into master
Read map input from file and display on screen
TODO: Display Collectibles and Exit
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -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; |
