diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 20:07:20 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 20:07:20 +0100 |
commit | 3ce74f6396bf76650853aba3bfc307847adb0bba (patch) | |
tree | 57f6040f2d1fd1e8ef59f20c3aa4c2157f404b5c /src/ft_draw_sprite_extra.c | |
parent | Ready to merge (diff) | |
parent | cangelog (diff) | |
download | 42-cub3d-3ce74f6396bf76650853aba3bfc307847adb0bba.tar.gz 42-cub3d-3ce74f6396bf76650853aba3bfc307847adb0bba.tar.bz2 42-cub3d-3ce74f6396bf76650853aba3bfc307847adb0bba.tar.xz 42-cub3d-3ce74f6396bf76650853aba3bfc307847adb0bba.tar.zst 42-cub3d-3ce74f6396bf76650853aba3bfc307847adb0bba.zip |
Merge branch 'better_sprites'
Diffstat (limited to 'src/ft_draw_sprite_extra.c')
-rw-r--r-- | src/ft_draw_sprite_extra.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 2545ec0..9198e8d 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -13,12 +13,11 @@ #include <libft.h> #include <cub3d.h> #include <stdint.h> -#include <stdio.h> #include <stdlib.h> #include <math.h> void - ft_sprite_height(t_cub *cl, t_sprite *sprite) + ft_sprite_h_w(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; @@ -27,11 +26,6 @@ void sprite->drawendy = sprite->spriteheight / 2 + cl->wlist.y_size / 2; if (sprite->drawendy >= (int)cl->wlist.y_size) sprite->drawendy = cl->wlist.y_size - 1; -} - -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) @@ -41,6 +35,7 @@ void sprite->drawendx = cl->wlist.x_size - 1; } + static void ft_init_sprite(t_cub *cl, t_sprite *sprite) { @@ -63,17 +58,17 @@ void i = 0; j = 0; + ft_sort_sprites(cl); while (j < cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) { - sprite = cl->sprites[j][i]; + sprite = cl->sprites[j][cl->mlist.sprite_order[j][i]]; sprite.current_sprite = (j == 0) ? 4 : j + 7; sprite.spritey = sprite.s_pos_x - (cl->plist.pos_x - 0.5); sprite.spritex = sprite.s_pos_y - (cl->plist.pos_y - 0.5); ft_init_sprite(cl, &sprite); - ft_sprite_height(cl, &sprite); - ft_sprite_width(cl, &sprite); + ft_sprite_h_w(cl, &sprite); ft_draw_sprite(cl, &sprite); i++; } |