aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_draw_sprite.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c
index fcb2166..fbe7961 100644
--- a/src/ft_draw_sprite.c
+++ b/src/ft_draw_sprite.c
@@ -39,17 +39,24 @@ void
{
float dist_tab[4096];
int32_t it;
+ int32_t jt;
it = 0;
- while (it < cl->mlist.sprite_nbr)
- {
- dist_tab[it] = ((cl->plist.pos_x - cl->sprites[0][it].s_pos_x) *
- (cl->plist.pos_x - cl->sprites[0][it].s_pos_x) +
- (cl->plist.pos_y - cl->sprites[0][it].s_pos_y) *
- (cl->plist.pos_y - cl->sprites[0][it].s_pos_y));
- cl->mlist.sprite_order[it] = it;
- it++;
- }
+ jt = 0;
+ while (jt < cl->mlist.sprite_var)
+ {
+ while (it < cl->mlist.sprite_nbr)
+ {
+ dist_tab[it] = ((cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) *
+ (cl->plist.pos_x - cl->sprites[jt][it].s_pos_x) +
+ (cl->plist.pos_y - cl->sprites[jt][it].s_pos_y) *
+ (cl->plist.pos_y - cl->sprites[jt][it].s_pos_y));
+ cl->mlist.sprite_order[it] = it;
+ it++;
+ }
+ it = 0;
+ jt++;
+ }
it = 0;
while (it < cl->mlist.sprite_nbr)
{
@@ -69,14 +76,14 @@ static void
calc = (calc >= 255) ? (255) : (calc);
calc = (calc < 1) ? (1) : (calc);
cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline)] =
- (uint8_t)cl->tlist[4].ptr[sprite->tex_x * 4 + 4 *
- cl->tlist[4].img_h * sprite->tex_y] / calc;
+ (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 *
+ cl->tlist[sprite->current_sprite].img_h * sprite->tex_y] / calc;
cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline) + 1] =
- (uint8_t)cl->tlist[4].ptr[sprite->tex_x * 4 + 4 *
- cl->tlist[4].img_h * sprite->tex_y + 1] / calc;
+ (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 *
+ cl->tlist[sprite->current_sprite].img_h * sprite->tex_y + 1] / calc;
cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline) + 2] =
- (uint8_t)cl->tlist[4].ptr[sprite->tex_x * 4 + 4 *
- cl->tlist[4].img_h * sprite->tex_y + 2] / calc;
+ (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 *
+ cl->tlist[sprite->current_sprite].img_h * sprite->tex_y + 2] / calc;
cl->img.ptr[sprite->x * 4 + cl->wlist.x_size * sprite->y + 3] = (char)0;
}
@@ -89,16 +96,16 @@ void
while (sprite->x < sprite->drawendx)
{
sprite->tex_x = (int32_t)((sprite->x - (-sprite->spritewidth / 2 +
- sprite->spritescreenx)) * cl->tlist[4].img_w / sprite->spritewidth);
+ sprite->spritescreenx)) * cl->tlist[sprite->current_sprite].img_w / sprite->spritewidth);
sprite->y = sprite->drawstarty;
while (sprite->y < sprite->drawendy)
{
d = sprite->y * 256 - cl->wlist.y_size * 128 +
sprite->spriteheight * 128;
- sprite->tex_y = ((d * cl->tlist[4].img_h / 2) /
+ sprite->tex_y = ((d * cl->tlist[sprite->current_sprite].img_h / 2) /
sprite->spriteheight) / 128;
- if (sprite->transformy > 0 && cl->tlist[4].ptr[sprite->tex_x * 4 + 4 *
- cl->tlist[4].img_h * sprite->tex_y]
+ if (sprite->transformy > 0 && cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 *
+ cl->tlist[sprite->current_sprite].img_h * sprite->tex_y]
&& cl->rlist.wall_dist_tab[sprite->x] > sprite->transformy)
{
ft_put_sprite(sprite, cl);