-
Notifications
You must be signed in to change notification settings - Fork 0
/
patrol_rendering.c
54 lines (49 loc) · 2.03 KB
/
patrol_rendering.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
/* ************************************************************************** */
/* */
/* :::::::: */
/* patrol_rendering.c :+: :+: */
/* +:+ */
/* By: cschuijt <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/12/28 00:59:41 by cschuijt #+# #+# */
/* Updated: 2022/12/28 00:59:41 by cschuijt ######## odam.nl */
/* */
/* ************************************************************************** */
#include "so_long.h"
#include <stdlib.h>
void render_patrols(t_map *map)
{
t_patrol *patrol;
int xy[2];
patrol = map->patrols;
while (patrol)
{
patrol->image = mlx_new_image(map->mlx, 48, 48);
free(patrol->image->pixels);
patrol->image->pixels = map->patrol_sprites[patrol->facing_offset];
xy[0] = render_x_pos(map, patrol->pos) - 8;
xy[1] = render_y_pos(map, patrol->pos) - 24;
mlx_image_to_window(map->mlx, patrol->image, xy[0], xy[1]);
mlx_set_instance_depth(&patrol->image->instances[0], layer_patrols);
patrol = patrol->next;
}
render_patrol_movement_indicators(map);
}
void render_patrol_movement_indicators(t_map *map)
{
t_patrol *patrol;
t_sprite *sprite;
mlx_instance_t *instance;
patrol = map->patrols;
sprite = find_or_create_sprite(map, map->bg_sprites, 13);
while (patrol)
{
patrol->indicator_instance = mlx_image_to_window(map->mlx, \
sprite->image, \
render_x_pos(map, patrol_indicator_pos(map, patrol)), \
render_y_pos(map, patrol_indicator_pos(map, patrol)));
instance = &sprite->image->instances[patrol->indicator_instance];
mlx_set_instance_depth(instance, layer_indicators);
patrol = patrol->next;
}
}