diff options
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r-- | src/ft_raycasting.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index dd2be64..589d2da 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -16,6 +16,17 @@ #include <math.h> void + ft_calc_sprite(t_cub *cl) +{ + cl->sp_list.s_x = cl->sp_list.s_pos_x - cl->plist->pos_x; + cl->sp_list.s_y = cl->sp_list.s_pos_y - cl->plist->pos_y; + cl->sp_list.inv_c_m = 1.0 / (cl->plist->plane_x * cl->plist->dir_x - cl->plist->dir_y * cl->plist->plane_y); + cl->sp_list.sprite_transform_x = cl->sp_list.inv_c_m * (cl->plist->dir_y * cl->sp_list.s_x - cl->plist->dir_x * cl->sp_list.s_y); + cl->sp_list.sprite_transform_y = cl->sp_list.inv_c_m * (cl->plist->plane_y * cl->sp_list.s_x - cl->plist->plane_x * cl->sp_list.s_y); + +} + +static void ft_calc_tex(t_cub *clist) { if (clist->rlist.side == 0) @@ -83,6 +94,7 @@ void cl->rlist.wall_b = wl->y_size - 1; ft_choose_tex(cl); ft_calc_tex(cl); + ft_calc_sprite(cl); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); i++; } |