-
Notifications
You must be signed in to change notification settings - Fork 0
/
inits.c
70 lines (62 loc) · 1.79 KB
/
inits.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* inits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 17:37:39 by hgrissen #+# #+# */
/* Updated: 2021/11/06 10:50:07 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
int get_coins(char **map)
{
int coins;
int i;
int j;
coins = 0;
i = 0;
while (map[i])
{
j = 0;
while (map[i][j])
{
if (map[i][j] == 'C')
coins++;
j++;
}
i++;
}
return (coins);
}
void init_player(t_mlx *mlx, char **map)
{
mlx->plyr = malloc(sizeof(t_player));
mlx->plyr->map = map;
mlx->plyr->step = 0;
mlx->plyr->end = 0;
mlx->plyr->collected = 0;
mlx->plyr->col_bool = 0;
mlx->plyr->coins = get_coins(mlx->plyr->map);
}
t_mlx *init_canvas(void)
{
t_mlx *mlx;
mlx = malloc(sizeof(t_mlx));
mlx->mlx = mlx_init();
mlx->mlx_win = mlx_new_window(mlx->mlx, g_width, g_height, "SO LONG");
mlx->img = mlx_new_image(mlx->mlx, g_width, g_height);
mlx->addr = mlx_get_data_addr(mlx->img, &mlx->bpp,
&mlx->ll, &mlx->end);
return (mlx);
}
void resolution(char **map)
{
int i;
i = 0;
while (map[i])
i++;
g_height = i * TILESIZE;
g_width = ft_strlen(map[2]) * TILESIZE;
}