mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
feat: player coordinate are at the center of a tile
This commit is contained in:
parent
15de3cc857
commit
76fba8fd8a
2 changed files with 5 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue