aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_traps_extra.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-03-11 18:06:17 +0100
committerRudy Bousset <rbousset@z2r4p1.le-101.fr>2020-03-11 18:06:17 +0100
commit7b61072321c71c1612a7b33d2e8d722a49c5bc99 (patch)
tree6369fc33d405013e40e152061bb080e6a5caabf8 /src/ft_draw_traps_extra.c
parentPerformance (diff)
download42-cub3d-7b61072321c71c1612a7b33d2e8d722a49c5bc99.tar.gz
42-cub3d-7b61072321c71c1612a7b33d2e8d722a49c5bc99.tar.bz2
42-cub3d-7b61072321c71c1612a7b33d2e8d722a49c5bc99.tar.xz
42-cub3d-7b61072321c71c1612a7b33d2e8d722a49c5bc99.tar.zst
42-cub3d-7b61072321c71c1612a7b33d2e8d722a49c5bc99.zip
ca tue
Diffstat (limited to '')
-rw-r--r--src/ft_draw_traps_extra.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ft_draw_traps_extra.c b/src/ft_draw_traps_extra.c
new file mode 100644
index 0000000..a2fd0ab
--- /dev/null
+++ b/src/ft_draw_traps_extra.c
@@ -0,0 +1,44 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_draw_traps_extra.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */
+/* Updated: 2020/03/09 18:56:01 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <math.h>
+
+void
+ ft_calc_trap(t_cub *cl)
+{
+ t_sprite sprite;
+ int32_t i;
+
+ i = 0;
+ while (i < cl->mlist.traps_nbr)
+ {
+ sprite = cl->traps[i];
+ sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5);
+ sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5);
+ sprite.invdet = 1.0 / (cl->plist.plane_x * cl->plist.dir_y
+ - cl->plist.dir_x * cl->plist.plane_y);
+ sprite.transformx = sprite.invdet * (cl->plist.dir_y * sprite.spritex
+ - cl->plist.dir_x * sprite.spritey);
+ sprite.transformy = sprite.invdet * (-cl->plist.plane_y * sprite.spritex
+ + cl->plist.plane_x * sprite.spritey);
+ sprite.spritescreenx = (int)(cl->wlist.x_size / 2) *
+ (1 + sprite.transformx / sprite.transformy);
+ ft_sprite_height(cl, &sprite);
+ ft_sprite_width(cl, &sprite);
+ ft_draw_traps(cl, &sprite);
+ i++;
+ }
+}