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> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:54:36 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 WIDTH 800
# define SIZE 64 # define SIZE 64
# define MAP_SIZE 20 # define MAP_SIZE 10
# define PLAYER_SIZE 6
# define RESSOURCE_DIR "ressources" # define RESSOURCE_DIR "ressources"
# define MOVEMENT_SPEED 0.000005 # define MOVEMENT_SPEED 0.000005
# define ROTATION_SPEED 0.000002 # define ROTATION_SPEED 0.000002

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:20:00 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 "../player/player.h"
#include "drawutils.h" #include "drawutils.h"
#include "../consts.h" #include "../consts.h"
#include "img_data.h"
void draw_2d_wall(unsigned int color, t_img_data *data, void draw_2d_wall(unsigned int color, t_img_data *data,
int x, int y) 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) void draw_map(t_mapdata *map, t_player *player, t_img_data *data)
{ {
int i; int i;
@ -59,5 +89,6 @@ void draw_map(t_mapdata *map, t_player *player, t_img_data *data)
} }
i++; 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);
} }