diff options
author | salaaad2 <arthudurant263@gmail.com> | 2020-03-18 18:59:59 +0100 |
---|---|---|
committer | salaaad2 <arthudurant263@gmail.com> | 2020-03-18 18:59:59 +0100 |
commit | 0036fe1e23be842e8baa48162bcdb3bf632b02de (patch) | |
tree | 3e457822a4905ef2021d141d3ec7f30b29a8d57a | |
parent | bunchoshit (diff) | |
download | 42-cub3d-0036fe1e23be842e8baa48162bcdb3bf632b02de.tar.gz 42-cub3d-0036fe1e23be842e8baa48162bcdb3bf632b02de.tar.bz2 42-cub3d-0036fe1e23be842e8baa48162bcdb3bf632b02de.tar.xz 42-cub3d-0036fe1e23be842e8baa48162bcdb3bf632b02de.tar.zst 42-cub3d-0036fe1e23be842e8baa48162bcdb3bf632b02de.zip |
gng
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | inc/cub3d.h | 4 | ||||
-rw-r--r-- | map/map_one.cub | 6 | ||||
-rw-r--r-- | src/ft_draw_sprite_extra.c | 12 | ||||
-rw-r--r-- | src/ft_draw_traps_extra.c | 3 | ||||
-rw-r--r-- | src/ft_sort_s_t.c | 24 |
6 files changed, 25 insertions, 27 deletions
@@ -97,7 +97,6 @@ SRCS_NAME += ft_sfx_trap.c SRCS_NAME += ft_sfx_new_level.c SRCS_NAME += ft_death_screen.c SRCS_NAME += ft_death_hooks.c -SRCS_NAME += ft_sort_s_t.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# @@ -133,7 +132,7 @@ else CC = gcc endif #--------------------------------------------------------------------------------------------------# -CFLAGS = -std=c99 +CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror diff --git a/inc/cub3d.h b/inc/cub3d.h index 4b52aab..9c906be 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -76,10 +76,8 @@ void ft_draw_circle(float a, float b, int32_t color, t_cub *cl); int8_t ft_draw_verline(t_cub *cl, int32_t x, int32_t y1, int32_t y2); -void ft_sprite_width(t_cub *cl, t_sprite *sprite); -void ft_sprite_height(t_cub *cl, t_sprite *sprite); +void ft_sprite_h_w(t_cub *cl, t_sprite *sprite); void ft_sort_sprites(t_cub *cl); -void ft_sort_s_t(t_cub *cl, t_sprite *sprites[4096]); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_calc_trap(t_cub *cl); diff --git a/map/map_one.cub b/map/map_one.cub index 244bd53..617a5e7 100644 --- a/map/map_one.cub +++ b/map/map_one.cub @@ -18,8 +18,8 @@ T ./media/img/spikes.xpm SH 2 111111111111111111 -140000000000300001 -100220E02200000001 +104000000002340001 +100000E00000000001 100100000000300001 101100000111000001 111111111111110011 @@ -27,7 +27,7 @@ SH 2 1001001 100001 1011001 100001 111101111111110111 -120500001101010111 +100500001101010111 100000000000000011 100000000000000011 11T000001101000111 diff --git a/src/ft_draw_sprite_extra.c b/src/ft_draw_sprite_extra.c index 6096522..9198e8d 100644 --- a/src/ft_draw_sprite_extra.c +++ b/src/ft_draw_sprite_extra.c @@ -17,7 +17,7 @@ #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; @@ -26,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) @@ -40,6 +35,7 @@ void sprite->drawendx = cl->wlist.x_size - 1; } + static void ft_init_sprite(t_cub *cl, t_sprite *sprite) { @@ -63,7 +59,6 @@ void i = 0; j = 0; ft_sort_sprites(cl); - ft_sort_s_t(cl, cl->sprites); while (j < cl->mlist.sprite_var) { while (i < cl->mlist.sprite_nbr) @@ -73,8 +68,7 @@ void 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++; } diff --git a/src/ft_draw_traps_extra.c b/src/ft_draw_traps_extra.c index a2fd0ab..c524190 100644 --- a/src/ft_draw_traps_extra.c +++ b/src/ft_draw_traps_extra.c @@ -36,8 +36,7 @@ void + cl->plist.plane_x * sprite.spritey); sprite.spritescreenx = (int)(cl->wlist.x_size / 2) * (1 + sprite.transformx / sprite.transformy); - ft_sprite_height(cl, &sprite); - ft_sprite_width(cl, &sprite); + ft_sprite_h_w(cl, &sprite); ft_draw_traps(cl, &sprite); i++; } diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c index f91804b..270c974 100644 --- a/src/ft_sort_s_t.c +++ b/src/ft_sort_s_t.c @@ -13,24 +13,32 @@ #include <libft.h> #include <cub3d.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <math.h> void - ft_sort_s_t(cl, t_sprite *s[4096]) + ft_sort_s_t(t_cub *cl, float dist_tab[8][4096]) { uint16_t i; - uint16_t j; - t_sprite tmp_s; + int32_t tmp; + t_sprite *tmp_s; i = 0; - j = 0; - while (i < cl->sprite_var) + tmp_s = ft_calloc(sizeof(t_sprite), 4096); + while (i < cl->mlist.sprite_var) { - if (s[i][0].) - { - + if (dist_tab[i][0] < dist_tab[i + 1][0]) + { + ft_memcpy(tmp_s, cl->sprites[i], 4096); + ft_memcpy(cl->sprites[i], cl->sprites[i + 1], 4096); + ft_memcpy(cl->sprites[i + 1], tmp_s, 4096); + tmp = dist_tab[i][0]; + dist_tab[i][0] = dist_tab[i + 1][0]; + dist_tab[i + 1][0] = tmp; + i = 0; } i++; + printf("qwe%d\n", i); } } |