-
Notifications
You must be signed in to change notification settings - Fork 1
/
Transition.cpp
124 lines (109 loc) · 2.3 KB
/
Transition.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "Transition.h"
Transition::Transition(GameDataRef p_data, std::string p_type, bool p_fullscreen) : m_data(p_data),
m_fullScreen(p_fullscreen)
{
this->m_brickShape.setTexture(this->m_data->assetManager.GetTexture("spritesheet"));
this->m_brickShape.setTextureRect(this->m_data->assetManager.GetRect("brick"));
this->m_brickShape.setColor(sf::Color(0, 0, 255, 255));
this->m_blackShape.setSize(sf::Vector2f(TILE_SIZE, TILE_SIZE));
this->m_blackShape.setFillColor(sf::Color(0, 0, 0, 255));
if (p_type == "FadeIn")
{
m_type = 0;
}
else
{
m_type = 1;
}
if (m_fullScreen)
{
m_maxline = 25;
}
else
{
m_maxline = 22;
for (size_t i = 0; i < 40; ++i)
{
for (size_t j = m_maxline; j < (25); ++j)
{
arr[i][j] = !m_type;
}
}
}
}
Transition::~Transition()
{
}
void Transition::Update(float dt)
{
if (this->m_isOver == false)
{
this->m_totalTime += dt;
if (this->m_totalTime > TRANSTION_TIME)
{
if (m_iStart >= 1)
{
m_iStart = m_iStart - 1;
m_jStart = m_jStart - 1;
}
for (size_t i = m_iStart; i < (40 - m_iStart); ++i)
{
for (size_t j = m_jStart; j < (m_maxline - m_jStart); ++j)
{
arr[i][j] = 1;
}
}
if (m_iStart == 0)
{
this->m_isCompleted = true;
this->m_isOver = true;
}
this->m_totalTime = 0;
}
}
m_brickShapeScaled = m_brickShape;
m_brickShapeScaled.setScale(m_brickShape.getScale() * SCALE_FACTOR);
}
void Transition::Draw()
{
size_t i = 0;
for (auto& line : arr)
{
size_t j = 0;
for (auto val : line)
{
if (val == m_type)
{
this->m_blackShape.setPosition(sf::Vector2f((float)i * (float)TILE_SIZE, (float)j * (float)TILE_SIZE));
this->m_brickShapeScaled.setPosition(sf::Vector2f((float)i * (float)TILE_SIZE, (float)j * (float)TILE_SIZE));
this->m_data->window.draw(m_blackShape);
this->m_data->window.draw(m_brickShapeScaled);
}
++j;
}
++i;
}
}
bool Transition::IsInProgress() const
{
if (!m_isOver && m_isStarted)
{
return true;
}
else
{
return false;
}
}
bool Transition::IsCompleted() const
{
if (m_isCompleted)
return true;
else
return false;
}
void Transition::Start()
{
m_isStarted = true;
m_isOver = false;
}