diff options
| author | Dominik Kaiser | 2024-05-20 20:30:41 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-05-20 20:30:41 +0200 |
| commit | 3ad8aa9e66f7e159b175a9a52e5ad00bbfd90734 (patch) | |
| tree | aaa06976a569ad3f3452121800e6bf33fc8d14ac /src/draw.c | |
| parent | e45d23fa56958a127c067e599d1408b030220ce8 (diff) | |
| download | so_long-3ad8aa9e66f7e159b175a9a52e5ad00bbfd90734.tar.gz so_long-3ad8aa9e66f7e159b175a9a52e5ad00bbfd90734.zip | |
Add collectibles
Exit now only works after collecting everything.
I don't really like my current solution, but it works for now.
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -6,7 +6,7 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 17:58:23 by dkaiser #+# #+# */ -/* Updated: 2024/05/15 17:31:11 by dkaiser ### ########.fr */ +/* Updated: 2024/05/20 20:10:15 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,10 +40,14 @@ int draw_walls(t_game *game) int y; mlx_texture_t *wall_texture; mlx_image_t *wall_image; + mlx_texture_t *collectible_texture; wall_texture = mlx_load_png("textures/wall.png"); wall_image = mlx_texture_to_image(game->mlx, wall_texture); + collectible_texture = mlx_load_png("textures/collectible.png"); + game->map.collectible_img = mlx_texture_to_image(game->mlx, collectible_texture); mlx_resize_image(wall_image, 48, 48); + mlx_resize_image(game->map.collectible_img, 48, 48); game->map.tile_size.x = 48; game->map.tile_size.y = 48; x = 0; @@ -55,6 +59,9 @@ int draw_walls(t_game *game) 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); + if (game->map.tiles[y * game->map.grid_size.x + x] == COLLECTIBLE) + mlx_image_to_window(game->mlx, game->map.collectible_img, x + * game->map.tile_size.x, y * game->map.tile_size.y); y++; } x++; |
