Skip to content

Commit

Permalink
Norm issue fixed, ready to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunghao-C committed Sep 4, 2024
1 parent ceaef01 commit 340563c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 40 deletions.
44 changes: 19 additions & 25 deletions srcs/frames/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand All @@ -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;
Expand All @@ -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)
{
Expand All @@ -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;
}
17 changes: 2 additions & 15 deletions srcs/raycasting/raycasting.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tsuchen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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;
Expand All @@ -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 ;
Expand Down

0 comments on commit 340563c

Please sign in to comment.