From 76fba8fd8a3fb01dc19dde12b1896a0f48105a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 29 Jul 2025 10:45:03 +0200 Subject: [PATCH] feat: player coordinate are at the center of a tile --- src/draw/draw_map.c | 4 ++-- src/main.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/draw/draw_map.c b/src/draw/draw_map.c index 264eacc..b174e80 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/17 15:55:44 by kcolin ### ########.fr */ +/* Updated: 2025/07/29 11:58:34 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,5 +59,5 @@ void draw_map(t_mapdata *map, t_player *player, t_img_data *data) } i++; } - draw_2d_wall(0x00FF0000, data, MAP_SIZE * (player->x / SIZE), MAP_SIZE * (player->y / SIZE)); + draw_2d_wall(0x00FF0000, data, MAP_SIZE * ((player->x - (float)SIZE / 2)) / SIZE, MAP_SIZE * ((player->y - (float)SIZE / 2) / SIZE)); } diff --git a/src/main.c b/src/main.c index 96b9c10..0e97ca7 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */ -/* Updated: 2025/07/29 10:30:41 by kcolin ### ########.fr */ +/* Updated: 2025/07/29 11:56:42 by kcolin ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,8 +32,8 @@ void init_player(t_mapdata *mapdata, t_player *player) { player->health = 100; - player->x = mapdata->startx * SIZE; - player->y = mapdata->starty * SIZE; + player->x = mapdata->startx * SIZE + ((float)SIZE / 2); + player->y = mapdata->starty * SIZE + ((float)SIZE / 2); if (mapdata->map[mapdata->starty][mapdata->startx] == 'N') player->yaw = M_PI; else if (mapdata->map[mapdata->starty][mapdata->startx] == 'S')