-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_check_sprit.c
68 lines (61 loc) · 1.8 KB
/
ft_check_sprit.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_check_sprit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hmoumani <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/22 18:32:48 by hmoumani #+# #+# */
/* Updated: 2020/11/22 18:32:49 by hmoumani ### ########.fr */
/* */
/* ************************************************************************** */
#include "lib.h"
void ft_calcul_dist(void)
{
t_list *curr;
int x;
int y;
curr = g_conf.sprite_head;
while (curr)
{
x = ((t_sprit *)curr->content)->x;
y = ((t_sprit *)curr->content)->y;
((t_sprit *)curr->content)->dis = distance_between(g_player.pos.x, \
g_player.pos.y, x, y);
curr = curr->next;
}
}
void sort_linked_list(t_list *start)
{
t_list *node;
t_list *temp;
t_sprit *tempvar;
node = start;
while (node != NULL)
{
temp = node;
while (temp->next != NULL)
{
if (((t_sprit *)temp->content)->dis < \
((t_sprit *)temp->next->content)->dis)
{
tempvar = (t_sprit *)temp->content;
temp->content = temp->next->content;
temp->next->content = (void *)tempvar;
}
temp = temp->next;
}
node = node->next;
}
}
void ft_rndr_sprit(void)
{
t_list *curr;
curr = g_conf.sprite_head;
sort_linked_list(curr);
while (curr)
{
render_sprite((t_sprit *)curr->content);
curr = curr->next;
}
}