-
Notifications
You must be signed in to change notification settings - Fork 0
/
movement.c
33 lines (30 loc) · 1.01 KB
/
movement.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
/*
** EPITECH PROJECT, 2022
** B-MUL-100-LYN-1-1-myradar-mael.rabot
** File description:
** movement
*/
#include "include/my.h"
void move_plane(plane_t *plane, float speed_mult)
{
if (visibility_check(plane) == TRUE) {
plane->pos.x += (plane->direction.x / 20) * speed_mult;
plane->pos.y += (plane->direction.y / 20) * speed_mult;
plane->rectangle_pos.x += (plane->direction.x / 20) * speed_mult;
plane->rectangle_pos.y += (plane->direction.y / 20) * speed_mult;
plane->hitbox.left = (plane->pos.x) * speed_mult;
plane->hitbox.top = (plane->pos.y) * speed_mult;
}
}
void update_position(launch_control_t *launch,
sfClock *clock, bool_t paused, float speed_mult)
{
if (sfClock_getElapsedTime(clock).microseconds / 1000000.0 > 0.005
&& paused == FALSE) {
sfClock_restart(clock);
for (int i = 0; i < launch->plane_nb; i++) {
move_plane(launch->plane_list[i], speed_mult);
landing(launch->plane_list[i]);
}
}
}