aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_draw_sprite.c
diff options
context:
space:
mode:
authorsalaaad2 <arthudurant263@gmail.com>2020-02-25 17:33:15 +0100
committersalaaad2 <arthudurant263@gmail.com>2020-02-25 17:33:15 +0100
commit51dd3734caadd0c3b943da3410772c65558280cc (patch)
tree20753d7dc65e749c849ad9eb1f0b003fe65bde2a /src/ft_draw_sprite.c
parentbunch of garbage (diff)
download42-cub3d-51dd3734caadd0c3b943da3410772c65558280cc.tar.gz
42-cub3d-51dd3734caadd0c3b943da3410772c65558280cc.tar.bz2
42-cub3d-51dd3734caadd0c3b943da3410772c65558280cc.tar.xz
42-cub3d-51dd3734caadd0c3b943da3410772c65558280cc.tar.zst
42-cub3d-51dd3734caadd0c3b943da3410772c65558280cc.zip
???
Diffstat (limited to '')
-rw-r--r--src/ft_draw_sprite.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c
index 28ffb10..03d3ca7 100644
--- a/src/ft_draw_sprite.c
+++ b/src/ft_draw_sprite.c
@@ -18,31 +18,31 @@
#include <math.h>
void
- ft_draw_sprite(t_cub *cl)
+ ft_draw_sprite(t_cub *cl, t_sprite *sprite)
{
- int d;
- int tex_x;
- int tex_y;
-
- cl->sprites.x = cl->sprites.s_start_x;
- while (cl->sprites.x < cl->sprites.s_end_x)
+ int32_t d;
+ sprite->x = sprite->drawstartx;
+ while (sprite->x < sprite->drawendx)
{
- tex_x = (int)((cl->sprites.x - (-cl->sprites.s_w / 2 + cl->sprites.s_screen_x))
- * cl->tlist[4].img_w / cl->sprites.s_w);
- cl->sprites.y = cl->sprites.s_start_y;
- while (cl->sprites.y < cl->sprites.s_end_y)
- {
- d = cl->sprites.y * 256 - cl->wlist->y_size * 128 + cl->sprites.s_h * 128;
- tex_y = ((d * cl->tlist[4].img_h) / cl->sprites.s_h) / 256;
- if (*(cl->tlist[4].ptr + tex_x + tex_y * cl->tlist[4].sizeline / 4))
+ sprite->tex_x = (int32_t)((sprite->x - (-sprite->spritewidth / 2 +
+ sprite->spritescreenx)) * cl->tlist[4].img_w / sprite->spritewidth);
+ sprite->y = sprite->drawstarty;
+ if (sprite->transformy > 0 && sprite->x >= 0 &&
+ sprite->x < (int32_t)cl->wlist->x_size)
+ while (sprite->y < sprite->drawendy)
{
- cl->img.ptr[tex_x * 4 + (cl->img.sizeline * tex_y)] =
- (char)cl->tlist[4].ptr[cl->tlist[4].tex_x * 4 + 4 *
- cl->tlist[4].img_h * tex_y];
- /*puts("qwe");*/
+ d = (sprite->y) * 256 - cl->wlist->y_size * 128 +
+ sprite->spriteheight * 128;
+ sprite->tex_y = ((d * cl->tlist[4].img_h) /
+ sprite->spriteheight) / 256;
+ if (*(cl->tlist[4].ptr + sprite->tex_x + sprite->tex_y *
+ cl->tlist[4].sizeline / 4))
+ *(cl->img.ptr + sprite->x + sprite->y *
+ cl->img.sizeline / 4) =
+ *(cl->tlist[4].ptr + sprite->tex_x + sprite->tex_y * cl->tlist[4].sizeline / 4);
+ sprite->y++;
}
- cl->sprites.y++;
- }
- cl->sprites.x++;
+ sprite->x++;
}
+
}