-
Notifications
You must be signed in to change notification settings - Fork 3
/
put_imgs.c
54 lines (48 loc) · 1.79 KB
/
put_imgs.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* put_imgs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tblaase <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/06 16:04:13 by tblaase #+# #+# */
/* Updated: 2021/10/08 15:22:07 by tblaase ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void ft_put_background(t_data *data)
/* will fill the whole screen with background */
{
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 ft_put_object(t_data *data, char *relative_path)
/* puts the given object to the current position */
{
int img_width;
int img_height;
data->map->object = mlx_xpm_file_to_image(data->mlx, relative_path,
&img_width, &img_height);
mlx_put_image_to_window(data->mlx, data->win, data->map->object,
(data->map->x * IMG_W), (data->map->y * IMG_H));
}
void ft_put_player(t_data *data)
/* puts the player in the starting position */
{
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));
}