-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ceaef01
commit 340563c
Showing
2 changed files
with
21 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -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 ; | ||
|