/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* draw_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:20:00 by kcolin #+# #+# */ /* Updated: 2025/09/08 13:58:59 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ #include "../map/mapdata.h" #include "../player/player.h" #include "drawutils.h" #include "../consts.h" #include "img_data.h" void draw_2d_wall(unsigned int color, t_img_data *data, int x, int y) { int i; int j; i = 0; while (i < MAP_SIZE) { j = 0; while (j < MAP_SIZE) { my_mlx_pixel_put(data, x + i, y + j, color); j++; } i++; } } void draw_player(unsigned int color, t_img_data *data, int x, int y) { int i; int j; i = -(PLAYER_SIZE / 2); while (i < (PLAYER_SIZE / 2)) { j = -(PLAYER_SIZE / 2); while (j < (PLAYER_SIZE / 2)) { my_mlx_pixel_put(data, x + i, y + j, color); j++; } i++; } } void draw_heading(unsigned int color, t_img_data *data, t_player *player) { int x; int y; x = player->x * MAP_SIZE + player->dir_x * PLAYER_SIZE; y = player->y * MAP_SIZE + player->dir_y * PLAYER_SIZE; my_mlx_pixel_put(data, x, y, color); } void draw_map(t_mapdata *map, t_player *player, t_img_data *data) { int i; int j; i = 0; while (map->map[i]) { j = 0; while (map->map[i][j]) { if (map->map[i][j] == '1') draw_2d_wall(map->f_color, data, MAP_SIZE * j, MAP_SIZE * i); else if (map->map[i][j] == 'D' || map->map[i][j] == 'd') draw_2d_wall(0x00FF2E63, data, MAP_SIZE * j, MAP_SIZE * i); else if (map->map[i][j] == 's') draw_2d_wall(0x00E84545, data, MAP_SIZE * j, MAP_SIZE * i); else if (map->map[i][j] == 'M') draw_2d_wall(0x00F4CE14, data, MAP_SIZE * j, MAP_SIZE * i); j++; } i++; } draw_player(0x00FF0000, data, MAP_SIZE * player->x, MAP_SIZE * player->y); draw_heading(0x00FFFFFF, data, player); }