dev: changed the c var in place_base_sprites to a counter in data struct

This commit is contained in:
Theo Champion 2025-08-14 21:38:49 +02:00
parent 4a70e44697
commit 0d6cc4063a
2 changed files with 6 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/17 14:59:37 by kcolin #+# #+# */
/* Updated: 2025/08/11 11:59:21 by tchampio ### ########.fr */
/* Updated: 2025/08/14 21:36:15 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -40,6 +40,7 @@ typedef struct s_cub3d_data
int delta;
int last_tick;
t_sprite **sprite_list;
int sprite_counter;
double zbuffer[WIDTH];
int sprite_order[MAX_SPRITES];
double sprite_distances[MAX_SPRITES];

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */
/* Updated: 2025/08/14 21:26:14 by tchampio ### ########.fr */
/* Updated: 2025/08/14 21:37:58 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,10 +58,8 @@ void place_base_sprites(t_cub3d_data *data, char **map)
{
int y;
int x;
int c;
y = 0;
c = 0;
while (y < data->map->mapheight)
{
x = 0;
@ -70,9 +68,9 @@ void place_base_sprites(t_cub3d_data *data, char **map)
if (map[y][x] == 'M' || map[y][x] == 'Q'
|| map[y][x] == 'J' || map[y][x] == 'D')
{
if (c < MAX_SPRITES)
data->sprite_list[c++] = place_right_sprite(data,
map[y][x], x, y);
if (data->sprite_counter < MAX_SPRITES)
data->sprite_list[data->sprite_counter++] =
place_right_sprite(data, map[y][x], x, y);
}
x++;
}