diff --git a/srcs/frames/sprite.c b/srcs/frames/sprite.c index d42979b..ed02f08 100644 --- a/srcs/frames/sprite.c +++ b/srcs/frames/sprite.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/04 09:59:13 by tsuchen #+# #+# */ -/* Updated: 2024/09/04 12:28:37 by tsuchen ### ########.fr */ +/* Updated: 2024/09/04 12:35:03 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,16 +15,13 @@ void play_sprite_forward(t_data *data, int map_x, int map_y) { t_frame *beg_frame; - void *door_img; - char *door_addr; - int door_h; - int door_w; + t_frame door_tmp; beg_frame = data->frames; - door_img = data->textures->text_img[D]; - door_addr = data->textures->text_addr[D]; - door_h = data->textures->tex_h[D]; - door_w = data->textures->tex_w[D]; + door_tmp.img = data->textures->text_img[D]; + door_tmp.addr = data->textures->text_addr[D]; + door_tmp.frm_h = data->textures->tex_h[D]; + door_tmp.frm_w = data->textures->tex_w[D]; while (beg_frame) { data->textures->text_img[D] = beg_frame->img; @@ -37,25 +34,22 @@ void play_sprite_forward(t_data *data, int map_x, int map_y) usleep(100000); } data->map[map_x][map_y] = 'O'; - data->textures->text_img[D] = door_img; - data->textures->text_addr[D] = door_addr; - data->textures->tex_h[D] = door_h; - data->textures->tex_w[D] = door_w; + data->textures->text_img[D] = door_tmp.img; + data->textures->text_addr[D] = door_tmp.addr; + data->textures->tex_h[D] = door_tmp.frm_h; + data->textures->tex_w[D] = door_tmp.frm_h; } void play_sprite_backward(t_data *data, int map_x, int map_y) { t_frame *beg_frame; - void *door_img; - char *door_addr; - int door_h; - int door_w; + t_frame door_tmp; beg_frame = lst_last(data->frames); - door_img = data->textures->text_img[D]; - door_addr = data->textures->text_addr[D]; - door_h = data->textures->tex_h[D]; - door_w = data->textures->tex_w[D]; + door_tmp.img = data->textures->text_img[D]; + door_tmp.addr = data->textures->text_addr[D]; + door_tmp.frm_h = data->textures->tex_h[D]; + door_tmp.frm_w = data->textures->tex_w[D]; data->map[map_x][map_y] = 'D'; while (beg_frame) { @@ -68,8 +62,8 @@ void play_sprite_backward(t_data *data, int map_x, int map_y) beg_frame = beg_frame->prev; usleep(100000); } - data->textures->text_img[D] = door_img; - data->textures->text_addr[D] = door_addr; - data->textures->tex_h[D] = door_h; - data->textures->tex_w[D] = door_w; + data->textures->text_img[D] = door_tmp.img; + data->textures->text_addr[D] = door_tmp.addr; + data->textures->tex_h[D] = door_tmp.frm_h; + data->textures->tex_w[D] = door_tmp.frm_h; } diff --git a/srcs/raycasting/raycasting.c b/srcs/raycasting/raycasting.c index fd26937..ee9b5c8 100644 --- a/srcs/raycasting/raycasting.c +++ b/srcs/raycasting/raycasting.c @@ -6,7 +6,7 @@ /* By: tsuchen +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/15 12:13:34 by tsuchen #+# #+# */ -/* Updated: 2024/09/04 11:34:53 by tsuchen ### ########.fr */ +/* Updated: 2024/09/04 12:37:01 by tsuchen ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,18 +46,6 @@ int rc_dda(t_vec *dist, t_vec *unit_dist, t_vec *pos, t_vec *dir) } } -static int is_door(t_data *data, int map_x, int map_y) -{ - if (data->map[map_x][map_y] == 'D') - return (1); - else if (data->map[map_x][map_y] == 'S') - return (2); - else if (data->map[map_x][map_y] == 's') - return (3); - else - return (0); -} - double rc_raydist(t_vec *ray, t_data *data) { t_vec ray_pos; @@ -74,8 +62,7 @@ double rc_raydist(t_vec *ray, t_data *data) data->side = rc_dda(&dist_ray, &unit_dist, &ray_pos, ray); if (data->map[(int)ray_pos.x][(int)ray_pos.y] == '1') break ; - if (is_door(data, (int)ray_pos.x, (int)ray_pos.y)) - // if (data->map[(int)ray_pos.x][(int)ray_pos.y] == 'D') + if (data->map[(int)ray_pos.x][(int)ray_pos.y] == 'D') { ray->door = TRUE; break ;