diff --git a/include/meta.h b/include/meta.h index d8ce814..3fc4dc3 100644 --- a/include/meta.h +++ b/include/meta.h @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ -/* :::::::: */ -/* meta.h :+: :+: */ -/* +:+ */ -/* By: joppe +#+ */ -/* +#+ */ +/* :::::::: */ +/* meta.h :+: :+: */ +/* +:+ */ +/* By: joppe +#+ */ +/* +#+ */ /* Created: 2024/02/05 14:01:44 by joppe #+# #+# */ -/* Updated: 2024/02/05 14:01:52 by joppe ######## odam.nl */ +/* Updated: 2024/02/08 13:54:31 by yzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -218,7 +218,7 @@ typedef struct s_attr { t_rgba ceiling_c; uint32_t sprite_count; uint32_t sprite_arr_index; - t_sprite *sprites; // we need to make the sprite count modular + t_sprite *sprites; } t_attr; typedef struct s_minimap { diff --git a/src/game/sprite.c b/src/game/sprite.c index e39be1f..ce85db3 100644 --- a/src/game/sprite.c +++ b/src/game/sprite.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ -/* :::::::: */ -/* sprite.c :+: :+: */ -/* +:+ */ -/* By: jboeve +#+ */ -/* +#+ */ +/* :::::::: */ +/* sprite.c :+: :+: */ +/* +:+ */ +/* By: jboeve +#+ */ +/* +#+ */ /* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */ -/* Updated: 2024/02/07 12:48:55 by yzaim ######## odam.nl */ +/* Updated: 2024/02/08 14:09:34 by yzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -68,8 +68,9 @@ void sprite_calculate(t_player *p) const t_vec2d s_pos = (t_vec2d){sp[p->sprite_order[i]].pos.x - p->position.x, sp[p->sprite_order[i]].pos.y - p->position.y}; - const double inv_det = 1.0 / (p->cam_plane.x * p->direction.y) - (p->cam_plane.y * p->direction.x); - + const double inv_det = 1.0 / (p->cam_plane.x * p->direction.y - p->direction.x * p->cam_plane.y); + + printf("invdet [%lf]\n", inv_det); const t_vec2d transform = {inv_det * (p->direction.y * s_pos.x - p->direction.x * s_pos.y), inv_det * (-(p->cam_plane.y) * s_pos.x + p->cam_plane.x * s_pos.y)}; diff --git a/src/game/sprite_utils.c b/src/game/sprite_utils.c index ccbca0e..6bce896 100644 --- a/src/game/sprite_utils.c +++ b/src/game/sprite_utils.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ -/* :::::::: */ -/* sprite_utils.c :+: :+: */ -/* +:+ */ -/* By: jboeve +#+ */ -/* +#+ */ +/* :::::::: */ +/* sprite_utils.c :+: :+: */ +/* +:+ */ +/* By: jboeve +#+ */ +/* +#+ */ /* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */ -/* Updated: 2024/01/29 12:50:12 by yesimzaim ######## odam.nl */ +/* Updated: 2024/02/08 14:06:22 by yzaim ######## odam.nl */ /* */ /* ************************************************************************** */ @@ -66,7 +66,27 @@ void quick_sort(double *sprite_dist, int32_t *sprite_order, int32_t low, int32_t } } +void reverse(double *arr1, int32_t *arr2, uint32_t size) +{ + uint32_t i; + double tmp1; + int32_t tmp2; + + i = 0; + while (i < size / 2) + { + tmp1 = arr1[i]; + arr1[i] = arr1[size - i - 1]; + arr1[size - i - 1] = tmp1; + tmp2 = arr2[i]; + arr2[i] = arr2[size - i - 1]; + arr2[size - i - 1] = tmp2; + i++; + } +} + void sprite_sort(double *sprite_dist, int32_t *sprite_order, uint32_t sprite_count) { quick_sort(sprite_dist, sprite_order, 0, sprite_count - 1); + // reverse(sprite_dist, sprite_order, sprite_count); } diff --git a/test_maps/valid_tex.cub b/test_maps/valid_tex.cub index f4884b9..0c13a2d 100644 --- a/test_maps/valid_tex.cub +++ b/test_maps/valid_tex.cub @@ -5,18 +5,17 @@ SO texture_examples/purplestone2.png F texture_examples/floor.png C texture_examples/ceiling_square.png -SP texture_examples/barrel.png 3.5 2.5 -SP texture_examples/barrel.png 4.5 2.5 +SP texture_examples/pillar.png 4.5 2.5 SP texture_examples/barrel.png 5.5 2.5 SP texture_examples/hoofd.png 6.5 2.5 SP texture_examples/sexy.png 7.5 2.5 -11111111111111 -1000000001 -1000000001 -1000000001 -1000000001 -1111101111 +11111111111111 +1000000001 +1000000001 +1000000001 +1000000001 +1111101111 111000N00111 100000000001 10000000011