tile size constant to make it clearer

This commit is contained in:
Quinten Mennen 2025-04-17 20:15:13 +02:00
parent 5db6f3e138
commit 0b8f71e680
2 changed files with 7 additions and 8 deletions

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 12:22:29 by qmennen #+# #+# */
/* Updated: 2025/04/17 20:08:39 by qmennen ### ########.fr */
/* Updated: 2025/04/17 20:13:46 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,6 +31,7 @@
# define WHITE "\033[0;37m"
# define NUM_KEYS 256
# define TILE_SIZE 16
# include <MLX42.h>
# include <libft.h>

View File

@ -6,7 +6,7 @@
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 16:28:10 by qmennen #+# #+# */
/* Updated: 2025/04/17 20:08:46 by qmennen ### ########.fr */
/* Updated: 2025/04/17 20:14:43 by qmennen ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,18 +27,16 @@ void render_tile(t_screen *screen, int x, int y, t_tile tile)
i = 0;
if (tile == 0)
return ;
while ((i++) < 16 * 16)
while ((i++) < TILE_SIZE * TILE_SIZE)
{
xp = x + (i % 16);
yp = y + (i / 16);
xp = x + (i % TILE_SIZE);
yp = y + (i / TILE_SIZE);
if (xp < 0 || xp >= screen->width || yp < 0 || yp >= screen->height)
continue;
if (tile == TILE_WALL)
{
mlx_put_pixel(screen->img, xp, yp, 0xA88132ff);
}
}
}
void render_map(t_screen *screen, t_map *map)
{
@ -53,7 +51,7 @@ void render_map(t_screen *screen, t_map *map)
y = i / map->height;
if (x < 0 || x >= map->width || y < 0 || y >= map->height)
continue;
render_tile(screen, x * 16, y * 16, map->grid[x][y]);
render_tile(screen, x * TILE_SIZE, y * TILE_SIZE, map->grid[x][y]);
i++;
}
}