-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprite_bonus.c
54 lines (50 loc) · 1.63 KB
/
sprite_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sprite_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: melkholy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/07 17:10:08 by melkholy #+# #+# */
/* Updated: 2022/10/07 22:23:56 by melkholy ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long_bonus.h"
void ft_walk_through(t_graph *graph, int row, int col)
{
if (graph->cats != graph->awake)
{
ft_printf("You have to wake up all Kiwis!\n");
ft_change_position(graph, row, col);
}
else
{
ft_printf("Great Job! You Won :)\n");
ft_free_destroy(graph);
}
}
int ft_render(t_graph *graph)
{
static int p_num;
static int g_num;
int row;
int col;
row = -1;
usleep(100000);
while (graph->map[++row])
{
col = -1;
while (graph->map[row][++col])
{
if (graph->map[row][col] == 'P')
ft_put_image(graph, graph->ply_img[p_num], row, col);
else if (graph->map[row][col] == 'G')
ft_put_image(graph, graph->gol_img[g_num], row, col);
}
}
if (++p_num == 18)
p_num = 0;
if (++g_num == 12)
g_num = 0;
return (0);
}