-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading.c
More file actions
52 lines (45 loc) · 1.21 KB
/
Copy pathloading.c
File metadata and controls
52 lines (45 loc) · 1.21 KB
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
/*
** EPITECH PROJECT, 2020
** MUL_my_rpg_2019
** File description:
** create_sprite
*/
#include <stdlib.h>
#include "filepath.h"
#include "game.h"
#include "main.h"
static unsigned int get_nb_type(void)
{
unsigned int len = 0;
for (; fp[len] != NULL; len++);
return (len);
}
sfTexture **create_texture(void)
{
sfTexture **textures = malloc(sizeof(sfTexture *) * get_nb_type());
if (textures == NULL)
return (NULL);
for (unsigned int y = 0; fp[y] != NULL; y++) {
textures[y] = sfTexture_createFromFile(fp[y], NULL);
if (!textures[y])
return (false);
}
return (textures);
}
object_t **load_all_object(sfTexture **textures)
{
object_t **objects = malloc(sizeof(object_t *) * (get_nb_type() + 1));
unsigned int y = 0;
if (objects == NULL)
return (NULL);
for (; fp[y] != NULL; y++) {
objects[y] = malloc(sizeof(object_t) * number_objects);
if (objects[y] == NULL)
return (NULL);
for (unsigned int x = 0; x < number_objects; x++)
objects[y][x] = create_object(textures_rects[y],
(sfVector2f) {-50000, -50000}, textures[y]);
}
objects[y] = NULL;
return (objects);
}