blob: 020f169a8f4da351bece271153bd60a058159252 (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_init_sprites.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:53 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:53 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
/*
** cl->sprite[] index summary
** --------------------------
** 0: sprite 2 - tlist[4] - 4096
** 1: sprite 3 - tlist[8] - 4096
** 2: sprite 4 - tlist[9] - 4096
** 3: sprite 5 - tlist[10] - 4096
** 4: sprite 6 - tlist[11] - 4096
** 5: sprite 7 - tlist[12] - 4096
** 6: sprite 8 - tlist[13] - 4096
** 7: sprite 9 - tlist[14] - 4096
** 8: trap - tlist[15] - 512
** 9: heal - tlist[17] - 64
** 10: weapon one - tlist[18] - 4
** 11: weapon two - tlist[19] - 4
** 12: weapon three - tlist[20] - 4
** 13: enemy - tlist[23] |
** '- - - - - - - tlist[24] |
** '- - - - - - - tlist[25] |
** '- - - - - - - tlist[26] - 32
*/
int8_t
ft_init_sprites(t_sprite ***sprites)
{
int8_t i;
if (!(*sprites = (t_sprite**)ft_calloc(FT_TOTAL_SPRT, sizeof(t_sprite*))))
return (-1);
i = -1;
while (++i < 8)
{
if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4096, sizeof(t_sprite))))
return (-1);
}
if (!(*((*sprites) + 8) = (t_sprite*)ft_calloc(512, sizeof(t_sprite))))
return (-1);
if (!(*((*sprites) + 9) = (t_sprite*)ft_calloc(64, sizeof(t_sprite))))
return (-1);
i = 9;
while (++i < 13)
{
if (!(*((*sprites) + i) = (t_sprite*)ft_calloc(4, sizeof(t_sprite))))
return (-1);
}
if (!(*((*sprites) + 13) = (t_sprite*)ft_calloc(32, sizeof(t_sprite))))
return (-1);
return (0);
}
|