-
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.
sprites dont go through walls anymore
- Loading branch information
Yesim Zaim
committed
Feb 8, 2024
1 parent
7fea4ea
commit a3d4a3c
Showing
6 changed files
with
36 additions
and
24 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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: joppe <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/02/05 14:01:44 by joppe #+# #+# */ | ||
/* Updated: 2024/02/08 13:54:31 by yzaim ######## odam.nl */ | ||
/* Updated: 2024/02/08 15:08:42 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -309,7 +309,7 @@ void sprite_calculate(t_player *p); | |
|
||
// test_utils.c REMOVE LATER | ||
|
||
void print_double_array(char *msg, double *arr, uint32_t size); | ||
void print_double_array(char *msg, double *arr, uint32_t size, t_sprite *sp, int32_t *order); | ||
void print_ints_array(char *msg, int32_t *arr, uint32_t size); | ||
void print_sprites_array(t_sprite *arr, uint32_t size); | ||
void print_attributes(t_attr *attributes); | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */ | ||
/* Updated: 2024/02/08 14:09:34 by yzaim ######## odam.nl */ | ||
/* Updated: 2024/02/08 15:09:00 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -53,13 +53,15 @@ void sprite_calculate(t_player *p) | |
while (i < p->meta->attributes.sprite_count) | ||
{ | ||
p->sprite_order[i] = i; | ||
p->sprite_dist[i] = (p->position.x - p->meta->attributes.sprites[i].pos.x) * (p->position.x - p->meta->attributes.sprites[i].pos.x) + (p->position.y - p->meta->attributes.sprites[i].pos.y) * (p->position.y - p->meta->attributes.sprites[i].pos.y); | ||
t_vec2d sp_pos = p->meta->attributes.sprites[i].pos; | ||
p->sprite_dist[i] = ((p->position.x - sp_pos.x) * (p->position.x - sp_pos.x)) + ((p->position.y - sp_pos.y) * (p->position.y - sp_pos.y)); | ||
i++; | ||
} | ||
|
||
sprite_sort(p->sprite_dist, p->sprite_order, p->meta->attributes.sprite_count); | ||
|
||
// print_double_array("SPRITE DIST", p->sprite_dist, p->meta->attributes.sprite_count); | ||
print_ints_array("SPRITE ORDER", p->sprite_order, p->meta->attributes.sprite_count); | ||
print_double_array("SPRITE DIST", p->sprite_dist, p->meta->attributes.sprite_count, p->meta->attributes.sprites, p->sprite_order); | ||
|
||
i = 0; | ||
while (i < p->meta->attributes.sprite_count) | ||
|
@@ -69,8 +71,6 @@ void sprite_calculate(t_player *p) | |
|
||
|
||
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jboeve <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */ | ||
/* Updated: 2024/02/08 14:06:22 by yzaim ######## odam.nl */ | ||
/* Updated: 2024/02/08 15:13:24 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -52,7 +52,7 @@ uint32_t partition(double *sprite_dist, int32_t *sprite_order, int32_t low, int3 | |
} | ||
} | ||
swap_doubles(&sprite_dist[low], &sprite_dist[j]); | ||
swap_ints(&sprite_order[low], &sprite_order[i]); | ||
swap_ints(&sprite_order[low], &sprite_order[j]); | ||
return (j); | ||
} | ||
|
||
|
@@ -88,5 +88,5 @@ void reverse(double *arr1, int32_t *arr2, uint32_t size) | |
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); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* test_utils.c :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: yzaim <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/01/08 15:25:38 by yzaim #+# #+# */ | ||
/* Updated: 2024/01/26 16:10:28 by yzaim ######## odam.nl */ | ||
/* :::::::: */ | ||
/* test_utils.c :+: :+: */ | ||
/* +:+ */ | ||
/* By: yzaim <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2024/01/08 15:25:38 by yzaim #+# #+# */ | ||
/* Updated: 2024/02/08 15:08:32 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -77,16 +77,24 @@ void print_map_cell(t_cell_type *level, uint32_t w, uint32_t h) | |
} | ||
} | ||
|
||
void print_double_array(char *msg, double *arr, uint32_t size) | ||
void print_double_array(char *msg, double *arr, uint32_t size, t_sprite *sp, int32_t *order) | ||
{ | ||
printf("%s :", msg); | ||
printf("%s: ", msg); | ||
for (int i = 0; i < size; i++) | ||
{ | ||
printf("%lf", arr[i]); | ||
if (i < size - 1) | ||
printf(" | "); | ||
} | ||
printf("\n"); | ||
printf("TEXTURES: "); | ||
for (int i = 0; i < size; i++) | ||
{ | ||
printf("%s", sp[order[i]].tex.tex_path + 17); | ||
if (i < size - 1) | ||
printf(" | "); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
void print_ints_array(char *msg, int32_t *arr, uint32_t size) | ||
|
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