aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2020-02-21 21:44:26 +0100
committersalaaad2 <arthurdurant263@gmail.com>2020-02-21 21:44:26 +0100
commit2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e (patch)
treebd46024aafd3a00d6ba9e140a7e8d4473c8a7bed /src/ft_raycasting.c
parenton est la (diff)
download42-cub3d-2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e.tar.gz
42-cub3d-2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e.tar.bz2
42-cub3d-2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e.tar.xz
42-cub3d-2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e.tar.zst
42-cub3d-2bc91ff7a1cdb2c7a97df74d89609e0c3ca1bb8e.zip
que des maths
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r--src/ft_raycasting.c12
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++;
}