-
Notifications
You must be signed in to change notification settings - Fork 0
/
next_frame.c
60 lines (54 loc) · 1.7 KB
/
next_frame.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* next_frame.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rertzer <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 16:10:53 by rertzer #+# #+# */
/* Updated: 2023/01/05 10:06:43 by rertzer ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
static void nf_more_crabs(t_sldata *sldata)
{
unsigned int crab_nb;
crab_nb = crab_count(sldata);
if (sldata->loops > NEW_CRAB_TIMER * TIMER * crab_nb * crab_nb)
{
sldata->loops = 0;
crab_new(sldata);
sldata->redraw = 1;
}
}
static void nf_move_crabs(t_sldata *sldata)
{
if (sldata->loops % TIMER == 0)
{
crabs_move(sldata);
sldata->wings = (sldata->wings + 1) % WINGS_MOD;
sldata->redraw = 1;
}
}
static void nf_redraw(t_sldata *sldata)
{
if (sldata->redraw)
{
redraw(sldata);
sldata->redraw = 0;
crab_catch(sldata);
if (sldata->won != 0)
the_end(sldata);
}
}
int next_frame(t_sldata *sldata)
{
sldata->loops++;
nf_more_crabs(sldata);
nf_move_crabs(sldata);
if (sldata->pirate_loops % TIMER == 0)
pirate_move(sldata);
nf_redraw(sldata);
sldata->pirate_loops++;
return (1);
}