-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.c
67 lines (60 loc) · 1.91 KB
/
process.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jchapell <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/30 03:53:34 by lebojo #+# #+# */
/* Updated: 2023/05/30 22:48:18 by jchapell ### ########.fr */
/* */
/* ************************************************************************** */
#include "inc/proto.h"
int physics_process(t_level *l)
{
friction(l);
draw_screen(l);
hud_info(l, "");
return (0);
}
void player_process(t_level *l)
{
int max_speed;
max_speed = 6;
if (l->player.vel.x < max_speed && l->player.vel.x > -max_speed)
{
if (l->key[0] == 1)
l->player.vel.x -= 2;
if (l->key[2] == 1)
l->player.vel.x += 2;
}
if (l->player.vel.y < max_speed && l->player.vel.y > -max_speed)
{
if (l->key[1] == 1)
l->player.vel.y -= 2;
if (l->key[3] == 1)
l->player.vel.y += 2;
}
}
void animation_process(t_level *l)
{
if (l->time % 3 == 0)
anim_coins(l);
if (l->time % 3 == 0)
anim_player(l);
l->time++;
}
int level_selector_process(t_level *l)
{
char *at;
at = add_str("Actual time: ", ft_itoa(l->time), 2);
draw_bcgk(l, vector(0, 0), vector(350, 350));
mlx_string_put(l->prm.mlx, l->prm.mlx_win, 120, 93, 0x000000, at);
mlx_string_put(l->prm.mlx, l->prm.mlx_win, 120, 91, 0xFFFFFF, at);
free(at);
draw_menu_level(l, l->ls_pos);
player_position(l);
draw_player(l);
launch_level(l);
return (0);
}