-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.c
58 lines (53 loc) · 2.12 KB
/
init.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tblaase <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/07 19:07:33 by tblaase #+# #+# */
/* Updated: 2021/10/08 15:11:03 by tblaase ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static void ft_init_help(t_data *data)
/* only exists because of the 25 line limit */
{
char *relative_path;
int img_width;
int img_height;
relative_path = "./textures/ship_right.xpm";
data->img->player_right = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
relative_path = "./textures/background.xpm";
data->img->background = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
}
void ft_init(t_data *data, t_map *map)
/* initialises most of my used data inside the structs */
{
char *relative_path;
int img_width;
int img_height;
t_img *img;
data->map = map;
img = malloc(sizeof(t_img));
if (!img)
{
perror("Error\nmalloc failed\n");
exit(EXIT_FAILURE);
}
data->img = img;
relative_path = "textures/ship_up.xpm";
data->img->player_up = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
relative_path = "./textures/ship_left.xpm";
data->img->player_left = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
relative_path = "./textures/ship_down.xpm";
data->img->player_down = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
ft_init_help(data);
data->counter = 0;
data->collected = 0;
}