-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen_parralax.c
36 lines (33 loc) · 1.03 KB
/
screen_parralax.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
/*
** EPITECH PROJECT, 2021
** MyRUNNER
** File description:
** parralax effect
*/
#include "runner.h"
void parralax_effect_midground(myrunner_t *myh,
sfRenderWindow *window, sfEvent event)
{
int x = sfSprite_getPosition(myh->game_third_backbg).x;
int y = sfSprite_getPosition(myh->game_third_backbg).y;
sfVector2f posback = {24, -14};
if (x <= -999)
sfSprite_setPosition(myh->game_third_backbg,
myh->pos_game_third_backbg);
sfVector2f my_mover = {-5, 0};
sfSprite_move(myh->game_third_backbg, my_mover);
}
void parralax_effect_foreground(myrunner_t *myh,
sfRenderWindow *window, sfEvent event)
{
int x = sfSprite_getPosition(myh->game_second_backbg).x;
int y = sfSprite_getPosition(myh->game_second_backbg).y;
sfVector2f posback = {0, 0};
if (x <= -1050)
sfSprite_setPosition(myh->game_second_backbg,
myh->pos_game_second_backbg);
if (x % - 20 == 0)
spawn_random_obstacles(myh);
sfVector2f my_mover = {-1, 0};
sfSprite_move(myh->game_second_backbg, my_mover);
}