-
Notifications
You must be signed in to change notification settings - Fork 0
/
img_init_utils.c
68 lines (63 loc) · 2 KB
/
img_init_utils.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* img_init_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lstorey <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/26 14:41:53 by lstorey #+# #+# */
/* Updated: 2024/05/08 14:18:00 by lstorey ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
void load_e_images(t_game_list *game, t_image *img)
{
int y;
int x;
y = 0;
x = 0;
img->txt_e = mlx_load_png("textures/E_block.png");
if (img->txt_e == NULL)
exit (1);
img->img_e = mlx_texture_to_image(game->mlx_ptr, img->txt_e);
mlx_delete_texture(img->txt_e);
if (!mlx_resize_image(img->img_e, game->tile_size, game->tile_size))
exit(1);
while (game->map_array[y])
{
while (game->map_array[y][x])
{
if (game->map_array[y][x] == 'E')
mlx_image_to_window(game->mlx_ptr,
img->img_e, game->tile_size * x, game->tile_size * y);
x++;
}
x = 0;
y++;
}
}
void load_bg_img(t_game_list *game, t_image *img)
{
int y;
int x;
y = 0;
x = 0;
img->txt_bg = mlx_load_png("textures/BG.png");
if (img->txt_bg == NULL)
exit (1);
img->img_bg = mlx_texture_to_image(game->mlx_ptr, img->txt_bg);
mlx_delete_texture(img->txt_bg);
if (!mlx_resize_image(img->img_bg, game->tile_size, game->tile_size))
exit(1);
while (y < game->rows)
{
while (x < game->columns)
{
mlx_image_to_window(game->mlx_ptr, img->img_bg,
game->tile_size * x, game->tile_size * y);
x++;
}
x = 0;
y++;
}
}