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
This commit is contained in:
Khaïs COLIN 2025-08-05 15:15:08 +02:00
parent a46fdff49a
commit 1d6d97ef25
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
2 changed files with 36 additions and 4 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}