aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2020-02-29 20:34:02 +0100
committersalaaad2 <arthurdurant263@gmail.com>2020-02-29 20:34:02 +0100
commita1891c76be7688be7f9e213308b6af33e3d3dacf (patch)
tree853936a23986a4c11bd80384e86e9db2382c2adc /src/ft_raycasting.c
parentg (diff)
download42-cub3d-a1891c76be7688be7f9e213308b6af33e3d3dacf.tar.gz
42-cub3d-a1891c76be7688be7f9e213308b6af33e3d3dacf.tar.bz2
42-cub3d-a1891c76be7688be7f9e213308b6af33e3d3dacf.tar.xz
42-cub3d-a1891c76be7688be7f9e213308b6af33e3d3dacf.tar.zst
42-cub3d-a1891c76be7688be7f9e213308b6af33e3d3dacf.zip
debugging...
Diffstat (limited to '')
-rw-r--r--src/ft_raycasting.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 0173fe6..0cd4cc6 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -45,22 +45,30 @@ void
ft_calc_sprite(t_cub *cl)
{
t_sprite sprite;
+ static int i = 0;
+ float tmp_a;
+ float tmp_b;
sprite = cl->sprites;
- sprite.spritex = (sprite.spritex + 1) - cl->plist->pos_x;
- sprite.spritey = (sprite.spritey + 1) - cl->plist->pos_y;
- printf("%f%f\n", sprite.spritex, sprite.spritey);
+ tmp_a = cl->plist->dir_x;
+ tmp_b = cl->plist->dir_y;
+ sprite.spritex = sprite.spritex - (cl->plist->pos_x - 0.5);
+ sprite.spritey = sprite.spritey - (cl->plist->pos_y - 0.5);
+ printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, cl->plist->dir_x, cl->plist->dir_y, i);
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.spritey - cl->plist->dir_x * sprite.spritex);
sprite.transformy = sprite.invdet *
(-cl->plist->plane_y * sprite.spritex + cl->plist->plane_x * sprite.spritey);
- sprite.spritescreenx = (int)((cl->wlist->x_size / 2) *
+ sprite.spritescreenx = (int)((cl->wlist->y_size / 2) *
(1 + sprite.transformx / sprite.transformy));
ft_sprite_height(cl, &sprite);
ft_sprite_width(cl, &sprite);
ft_draw_sprite(cl, &sprite);
+ cl->plist->dir_x = tmp_a;
+ cl->plist->dir_y = tmp_b;
+ i++;
}
void