-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_world.c
More file actions
62 lines (56 loc) · 1.63 KB
/
Copy pathinit_world.c
File metadata and controls
62 lines (56 loc) · 1.63 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
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_world.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kamanfo <kamanfo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/24 16:06:24 by kamanfo #+# #+# */
/* Updated: 2022/01/01 20:05:43 by kamanfo ### ########.fr */
/* */
/* ************************************************************************** */
#include "init_tab.h"
t_player *init_player(int i, int j)
{
t_player *player;
t_Coord coord;
player = (t_player *)malloc(sizeof(t_player));
coord.y = i;
coord.x = j;
player->coord = coord;
player->dir = -1;
return (player);
}
void init_images(t_world *world)
{
init_imageset(world);
init_anim_player(world);
init_anim_enemy(world);
init_anim_chest(world);
}
t_world init_world(char **map, t_mlx *mlx)
{
int i;
int j;
t_world world;
i = 0;
world.nb_item = 0;
while (map[i])
{
j = 0;
while (is_mapset(map[i][j]))
{
if (map[i][j] == 'P')
world.player = init_player(i, j);
if (map[i][j] == 'C')
world.nb_item++;
j++;
}
i++;
}
world.map = map;
world.mlx = mlx;
world.count_move = 0;
init_images(&world);
return (world);
}