-
Notifications
You must be signed in to change notification settings - Fork 0
/
cub3d_sprite_allocation.c
executable file
·54 lines (47 loc) · 1.87 KB
/
cub3d_sprite_allocation.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_sprite_allocation.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mg <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/29 03:13:18 by mg #+# #+# */
/* Updated: 2020/10/07 22:34:45 by mg ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void c3d_sprite_malloc_map_grid(t_param *cub3d)
{
int i;
i = 0;
if (!(cub3d->map.row > 0 && cub3d->map.column > 0))
c3d_print_error(cub3d, "Sprite Map: Invalid Map Height or Width.");
cub3d->sprite.grid = malloc(cub3d->map.row * sizeof(t_sprite_grid *));
if (!cub3d->sprite.grid)
c3d_print_error_sys(cub3d, "SPRITE GRID #1");
while (i < cub3d->map.row)
{
cub3d->sprite.grid[i] =
malloc(cub3d->map.column * sizeof(t_sprite_grid));
if (!cub3d->sprite.grid[i] || !(cub3d->free.sprite_row = i + 1))
c3d_print_error_sys(cub3d, "SPRITE GRID #2");
++i;
}
}
void c3d_sprite_malloc_visible_arrary(t_param *cub3d)
{
uint size;
size = MAX_SPRITE * sizeof(t_sprite_info);
cub3d->sprite.visible = malloc(size);
if (!(cub3d->sprite.visible))
c3d_print_error_sys(cub3d, "SPRITE GRID");
}
void c3d_sprite_map_grid_free(t_param *cub3d)
{
int i;
i = -1;
if (cub3d->free.sprite_row)
while (++i < cub3d->free.sprite_row)
free(cub3d->sprite.grid[i]);
free(cub3d->sprite.grid);
}