-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the weird sprites through the wall issue
- Loading branch information
Yesim Zaim
committed
Feb 8, 2024
1 parent
ae3c212
commit 7fea4ea
Showing
4 changed files
with
49 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* meta.h :+: :+: */ | ||
/* +:+ */ | ||
/* By: joppe <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* :::::::: */ | ||
/* meta.h :+: :+: */ | ||
/* +:+ */ | ||
/* By: joppe <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* 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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* sprite.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* :::::::: */ | ||
/* sprite.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* 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)}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* :::::::: */ | ||
/* sprite_utils.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* :::::::: */ | ||
/* sprite_utils.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters