-
Notifications
You must be signed in to change notification settings - Fork 1
/
AnimationManager.hpp
53 lines (49 loc) · 1.23 KB
/
AnimationManager.hpp
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
#ifndef SNAKE_RG_AM_H_
#define SNAKE_RG_AM_H_
#include "WindowRender.hpp"
#include "Snake.hpp"
#include "GameObject.hpp"
#include "Food.hpp"
#include "Global.hpp"
namespace rg {
class BaseAnimation {
protected:
BaseAnimation() = default;
~BaseAnimation() = default;
sf::RenderWindow* window;
renderManager* render;
void handleEvent() {
sf::Event e;
while (window->pollEvent(e))
if (e.type == sf::Event::Closed)
window->close();
}
};
class AnimationSnake : BaseAnimation {
public:
explicit AnimationSnake(sf::RenderWindow& window, renderManager& render, Snake* snake);
~AnimationSnake() = default;
void display();
private:
const float flashing_interval = 0.2f;
const float delete_interval = 0.1f;
const int flash_times = 5;
int flashed_times = 0;
float time = 0.f;
bool show_snake = false;
sf::Clock clock;
Snake* snake;
};
class AnimationFade : BaseAnimation {
public:
explicit AnimationFade(sf::RenderWindow& window, renderManager& render, Wall* snake, Food* food, Background* background);
~AnimationFade() = default;
void display();
private:
int fade_color = 255;
Wall* wall;
Food* food;
Background* background;
};
}
#endif