aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_draw_sprite.c')
-rw-r--r--src/ft_draw_sprite.c10
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); */