From 2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Fri, 21 Feb 2020 21:44:26 +0100 Subject: que des maths --- src/ft_raycasting.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ft_raycasting.c') 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 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++; } -- cgit v1.2.3