diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2020-03-09 17:50:45 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2020-03-09 17:50:45 +0100 |
commit | 7d50a78eed9c6cfce3288c471b9f3e6367bfe040 (patch) | |
tree | dc53123db1690b93a1b2e00c842ff16251662937 /src/ft_draw_sprite.c | |
parent | sprites ont des jambes (diff) | |
download | 42-cub3d-7d50a78eed9c6cfce3288c471b9f3e6367bfe040.tar.gz 42-cub3d-7d50a78eed9c6cfce3288c471b9f3e6367bfe040.tar.bz2 42-cub3d-7d50a78eed9c6cfce3288c471b9f3e6367bfe040.tar.xz 42-cub3d-7d50a78eed9c6cfce3288c471b9f3e6367bfe040.tar.zst 42-cub3d-7d50a78eed9c6cfce3288c471b9f3e6367bfe040.zip |
gang
Diffstat (limited to 'src/ft_draw_sprite.c')
-rw-r--r-- | src/ft_draw_sprite.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index e412998..ffc2d50 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -82,8 +82,8 @@ void while (i < cl->mlist->sprite_nbr) { sprite = cl->sprites[i]; - sprite.spritey = sprite.s_pos_x - cl->plist->pos_x; - sprite.spritex = sprite.s_pos_y - cl->plist->pos_y; + 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); @@ -101,7 +101,6 @@ void int32_t d; sprite->x = sprite->drawstartx; - printf("y : [%d] [%d] x : [%d] [%d] x : [%f] y : [%f]\n", sprite->drawstarty, sprite->drawendy, sprite->drawstartx, sprite->drawendx, cl->plist->dir_x, cl->plist->dir_y); while (sprite->x < sprite->drawendx) { sprite->tex_x = (int32_t)((sprite->x - (-sprite->spritewidth / 2 + @@ -114,7 +113,7 @@ void sprite->tex_y = ((d * cl->tlist[4].img_h / 2) / sprite->spriteheight) / 128; if (cl->tlist[4].ptr[sprite->tex_x * 4 + 4 * cl->tlist[4].img_h * sprite->tex_y] - && cl->rlist.wall_dist_tab[sprite->x] > cl->rlist.wall_dist) + && cl->rlist.wall_dist_tab[sprite->x] > sprite->transformy) { cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline)] = cl->tlist[4].ptr[sprite->tex_x * 4 + 4 * cl->tlist[4].img_h * sprite->tex_y]; @@ -130,6 +129,3 @@ void sprite->x++; } } - - -/* printf("[%f] [%f] x [%f] y [%f] [%d]\n", sprite.spritex, sprite.spritey, sprite.transformx, sprite.transformy, i); */ |