-
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.
Merge branch 'parser_with_sprites' into doors
- Loading branch information
Showing
7 changed files
with
72 additions
and
39 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
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
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 17:31:59 by yzaim ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -52,21 +52,41 @@ 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); | ||
} | ||
|
||
void quick_sort(double *sprite_dist, int32_t *sprite_order, int32_t low, int32_t high) | ||
{ | ||
if (low < high) | ||
{ | ||
int32_t pivot = partition(sprite_dist, sprite_order, low, high); | ||
quick_sort(sprite_dist, sprite_order, low, pivot - 1); | ||
quick_sort(sprite_dist, sprite_order, pivot + 1, high); | ||
int32_t partition_index = partition(sprite_dist, sprite_order, low, high); | ||
quick_sort(sprite_dist, sprite_order, low, partition_index - 1); | ||
quick_sort(sprite_dist, sprite_order, partition_index + 1, high); | ||
} | ||
} | ||
|
||
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
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