-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollision.c
42 lines (37 loc) · 864 Bytes
/
collision.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
/*
** EPITECH PROJECT, 2022
** collision
** File description:
** collision
*/
#include "header.h"
void bouncing_x(chara *charac)
{
charac->dir_x *= -1;
charac->bounce += 1;
}
void bouncing_y(chara *charac)
{
charac->dir_y *= -1;
charac->bounce += 1;
}
void redirect_duck(chara *charac)
{
sfVector2f position = sfSprite_getPosition(charac->sprite);
if (position.x < 0 && charac->vect.x < 0) {
bouncing_x(charac);
charac->heading = 0;
move_rect(&charac->rect, 0, 330);
}
if (position.x > 1000 - 110 && charac->vect.x > 0) {
bouncing_x(charac);
charac->heading = 1;
move_rect(&charac->rect, 330, 660);
}
if (position.y < 0 && charac->vect.y < 0) {
bouncing_y(charac);
}
if (position.y > 700 - 110 && charac->vect.y > 0) {
bouncing_y(charac);
}
}