diff options
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r-- | src/ft_raycasting.c | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 925711f..2c4b05c 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -17,61 +17,6 @@ #include <stdlib.h> #include <math.h> -void - ft_sprite_height(t_cub *cl, t_sprite *sprite) -{ - sprite->spriteheight = abs((int)(cl->wlist->y_size / (sprite->transformy))); - sprite->drawstarty = -sprite->spriteheight / 2 + cl->wlist->y_size / 2; - if (sprite->drawstarty < 0) - sprite->drawstarty = 0; - sprite->drawendy = sprite->spriteheight / 2 + cl->wlist->y_size / 2; - if (sprite->drawendy >= (int)cl->wlist->y_size) - sprite->drawendy = cl->wlist->y_size; -} - -void - ft_sprite_width(t_cub *cl, t_sprite *sprite) -{ - sprite->spritewidth = abs((int)(cl->wlist->x_size / (sprite->transformy))); - sprite->drawstartx = -sprite->spritewidth / 2 + sprite->spritescreenx; - if (sprite->drawstartx < 0) - sprite->drawstartx = 0; - sprite->drawendx = sprite->spritewidth / 2 + sprite->spritescreenx; - if (sprite->drawendx >= (int)cl->wlist->x_size) - sprite->drawendx = cl->wlist->x_size; -} - -void - ft_calc_sprite(t_cub *cl) -{ - t_sprite sprite; - static int i = 0; - float tmp_a; - float tmp_b; - - sprite = cl->sprites; - 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); - /* sprite.transformx */ - /* sprite.transformy */ - printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, sprite.transformx, sprite.transformy, 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->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 ft_calc_tex(t_cub *clist) @@ -142,6 +87,7 @@ ft_castray(t_cub *cl) ft_choose_tex(cl); ft_calc_tex(cl); ft_draw_verline(cl, i, cl->rlist.wall_t, cl->rlist.wall_b); + cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist; i++; } } |