-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite_move.c
77 lines (70 loc) · 2.46 KB
/
sprite_move.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
69
70
71
72
73
74
75
76
77
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sprite_move.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phelebra <xhelp00@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/10 16:50:14 by jbartosi #+# #+# */
/* Updated: 2023/10/16 16:05:02 by phelebra ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void process_larry_jr_head(t_box *box, t_sprite_data *data)
{
if (data->texture == LARRY_JR_HEAD && data->state == AWAKE)
{
enemy_angle(box, data);
enemy_move(box, data);
}
}
void process_larry_jr_body(t_box *box, t_sprite_data *data)
{
if (data->texture == LARRY_JR_BODY && data->state == AWAKE)
{
body_angle(box, data);
enemy_move(box, data);
}
}
void process_leech_or_baby(t_box *box, t_sprite_data *data)
{
if ((data->texture == LEECH || data->texture == BABY) && data->state
== AWAKE)
{
enemy_angle(box, data);
enemy_move(box, data);
}
}
int determine_sprite_action(t_box *box, t_sprite_data *data, t_sprite *sprites)
{
if (data->texture < TEAR && data->texture != DOOR)
return (check_player_hit(box, data));
else if (data->texture == TEAR)
return (handle_tear(box, data, sprites));
else if (data->texture == ITEMS)
return (handle_item(box, data, sprites));
else if (data->texture == KEY && data->dist < 0.1 && data->dist != 0)
return (handle_key(box, sprites));
else if (data->texture == TROPHY && data->dist < 0.1 && data->dist != 0)
return (handle_trophy(box, sprites));
else if (data->texture == DOOR)
return (handle_door(box, data));
return (1);
}
void cal_sprite_move(t_box *box)
{
t_sprite *sprites;
int continue_loop;
sprites = box->sprites;
while (sprites)
{
process_larry_jr_head(box, sprites->data);
process_larry_jr_body(box, sprites->data);
process_leech_or_baby(box, sprites->data);
continue_loop = determine_sprite_action(box, sprites->data, sprites);
if (continue_loop)
sprites = sprites->next;
else
break ;
}
}