From 1d6d97ef258715a9585b46a67819938d4aaf6e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 5 Aug 2025 15:15:08 +0200 Subject: [PATCH] feat: enhance minimap rendering - add heading indicator - center of player icon is player position - player size is independent of map tile size - reduce minimap size --- src/consts.h | 5 +++-- src/draw/draw_map.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/consts.h b/src/consts.h index dd24edd..881abae 100644 --- a/src/consts.h +++ b/src/consts.h @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:54:36 by kcolin #+# #+# */ -/* Updated: 2025/07/31 15:02:18 by kcolin ### ########.fr */ +/* Updated: 2025/08/05 15:22:09 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,8 @@ # define WIDTH 800 # define SIZE 64 -# define MAP_SIZE 20 +# define MAP_SIZE 10 +# define PLAYER_SIZE 6 # define RESSOURCE_DIR "ressources" # define MOVEMENT_SPEED 0.000005 # define ROTATION_SPEED 0.000002 diff --git a/src/draw/draw_map.c b/src/draw/draw_map.c index ca0740f..b62931e 100644 --- a/src/draw/draw_map.c +++ b/src/draw/draw_map.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:20:00 by kcolin #+# #+# */ -/* Updated: 2025/07/29 14:16:07 by tchampio ### ########.fr */ +/* Updated: 2025/08/05 15:20:47 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #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) @@ -34,6 +35,35 @@ void draw_2d_wall(unsigned int color, t_img_data *data, } } +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; @@ -59,5 +89,6 @@ void draw_map(t_mapdata *map, t_player *player, t_img_data *data) } i++; } - draw_2d_wall(0x00FF0000, data, MAP_SIZE * player->x, MAP_SIZE * player->y); + draw_player(0x00FF0000, data, MAP_SIZE * player->x, MAP_SIZE * player->y); + draw_heading(0x00FFFFFF, data, player); }