-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplace_images.c
54 lines (48 loc) · 1.74 KB
/
place_images.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* place_images.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: szerisen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/21 16:04:13 by szerisen #+# #+# */
/* Updated: 2023/04/20 20:57:19 by szerisen ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void put_background(t_data *data)
{
int y;
int x;
y = 0;
while (y < data->size_y)
{
x = 0;
while (x < data->size_x)
{
mlx_put_image_to_window(data->mlx, data->win,
data->img->background, x, y);
x += IMG_W;
}
y += IMG_H;
}
}
void put_object(t_data *data, char *relative_path)
{
int img_width;
int img_height;
data->map->object = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
if (!data->map->object)
handle_error(data, "Error\nexit file not found", 1);
mlx_put_image_to_window(data->mlx, data->win, data->map->object,
(data->map->x * IMG_W), (data->map->y * IMG_H));
free(data->map->object);
}
void put_player(t_data *data)
{
data->p_x = data->map->x;
data->p_y = data->map->y;
mlx_put_image_to_window(data->mlx, data->win, data->img->player_up,
(data->p_x * IMG_W), (data->p_y * IMG_H));
}