From 0d432c6ba3f1ea996e060371e60706b3916afe1c Mon Sep 17 00:00:00 2001 From: Baptiste GOULARD Date: Sun, 1 Dec 2024 17:17:17 +0100 Subject: [PATCH] fix:mistake on merge port [Fix] Fixed pos_i on the moves (used on the draw calls) [Del] Removed trailling debug exit on search_hit func --- mlx_layer/mooves.c | 12 +++++++++++- raycast/frame_update.c | 7 +------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mlx_layer/mooves.c b/mlx_layer/mooves.c index 748fbe4..3c9f876 100644 --- a/mlx_layer/mooves.c +++ b/mlx_layer/mooves.c @@ -6,13 +6,19 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/28 14:10:44 by bgoulard #+# #+# */ -/* Updated: 2024/11/28 14:50:48 by bgoulard ### ########.fr */ +/* Updated: 2024/12/01 17:15:27 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ #include "cub3d.h" #include "cub3d_struct.h" +void update_pos_i(t_player *player) +{ + player->pos_i.x = (int)player->pos.x; + player->pos_i.y = (int)player->pos.y; +} + void move_straight(t_info *data) { t_tile *tile_x; @@ -26,6 +32,7 @@ void move_straight(t_info *data) (t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y + data->player.dir.y * MOVE_SPEED)}); if (tile_y->tile_type == EMPTY) data->player.pos.y += data->player.dir.y * MOVE_SPEED; + update_pos_i(&data->player); } void move_backward(t_info *data) @@ -41,6 +48,7 @@ void move_backward(t_info *data) (t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y - data->player.dir.y * MOVE_SPEED)}); if (tile_y->tile_type == EMPTY) data->player.pos.y -= data->player.dir.y * MOVE_SPEED; + update_pos_i(&data->player); } void move_left(t_info *data) @@ -59,6 +67,7 @@ void move_left(t_info *data) (t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y + pplayer.y * MOVE_SPEED)}); if (tile_y->tile_type == EMPTY) data->player.pos.y += pplayer.y * MOVE_SPEED; + update_pos_i(&data->player); } void move_right(t_info *data) @@ -77,4 +86,5 @@ void move_right(t_info *data) (t_ipoint){(int)data->player.pos.x, (int)(data->player.pos.y - pplayer.y * MOVE_SPEED)}); if (tile_y->tile_type == EMPTY) data->player.pos.y -= pplayer.y * MOVE_SPEED; + update_pos_i(&data->player); } diff --git a/raycast/frame_update.c b/raycast/frame_update.c index ff07526..d1593cc 100644 --- a/raycast/frame_update.c +++ b/raycast/frame_update.c @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/12 06:02:54 by bgoulard #+# #+# */ -/* Updated: 2024/11/29 17:01:14 by bgoulard ### ########.fr */ +/* Updated: 2024/12/01 17:09:40 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,11 +52,6 @@ void search_hit(t_dpoint *sideDist, t_dpoint deltaDist, t_ipoint *pos_i, t_ipoin pos_i->y += step.y; *side = 1; } - - if (data->map.size.x < 0 || data->map.size.y < 0 || - data->map.size.x > 100 || data->map.size.y > 100) - exit (EXIT_FAILURE); - if ((*c3_get_cell(data->map.map, data->map.size, *pos_i)) .tile_type != EMPTY) return ;