-
Notifications
You must be signed in to change notification settings - Fork 0
/
victory_window.c
59 lines (54 loc) · 1.75 KB
/
victory_window.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
/*
** EPITECH PROJECT, 2022
** B-MUL-100-LYN-1-1-myhunter-mael.rabot
** File description:
** fail_window
*/
#include "include/my.h"
sfSprite *make_victory_title(sfRenderWindow *window)
{
sfTexture *texture = sfTexture_createFromFile("ress/victory2.png", NULL);
sfSprite *sprite = sfSprite_create();
sfVector2f scale = {0.75, 0.75};
sfSprite_setScale(sprite, scale);
sfSprite_setTexture(sprite, texture, 0);
sfVector2f vect = {sfRenderWindow_getSize(window).x / 2 - 1921 * 0.75 / 2,
sfRenderWindow_getSize(window).y / 5};
sfSprite_setPosition(sprite, vect);
return (sprite);
}
sfSprite **make_vict_sprites(sfRenderWindow *window)
{
sfSprite **res;
res = malloc(8 * 10);
sfTexture *bck = sfTexture_createFromFile("ress/bg_sheet.png", NULL);
sfSprite *back = sfSprite_create();
sfSprite_setTexture(back, bck, 0);
res[0] = back;
res[1] = make_ship();
res[2] = make_victory_title(window);
return (res);
}
void draw_victory(sfRenderWindow *window, sfSprite **list)
{
sfRenderWindow_drawSprite(window, list[0], NULL);
sfRenderWindow_drawSprite(window, list[1], NULL);
sfRenderWindow_drawSprite(window, list[2], NULL);
}
void victory_window(sfRenderWindow *window)
{
sfClock *clock = sfClock_create();
sfVector2f mvment = {-1, 0};
sfSprite **list = make_vict_sprites(window);
sfSprite *cursor = make_ptr();
while (sfRenderWindow_isOpen(window)) {
close_event(window);
(sfSprite_getPosition(list[0]).x < -1920 * 6) ?
sfSprite_setPosition(list[0], mvment) : "";
sfRenderWindow_clear(window, sfBlack);
sfSprite_move(list[0], mvment);
draw_victory(window, list);
move_ptr(window, cursor);
sfRenderWindow_display(window);
}
}