-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpike.cpp
46 lines (35 loc) · 1.34 KB
/
Spike.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
#include "Spike.h"
Spike::Spike(float a_dSpikeHeight, sf::Vector2f &a_oPosition) {
m_dSpikeHeight = a_dSpikeHeight;
m_oPosition = a_oPosition;
m_oTriangle.setPointCount(3);
m_oTriangle.setPoint(0, sf::Vector2f(m_oPosition.x + (m_dSpikeHeight / 2), m_oPosition.y));
m_oTriangle.setPoint(1, sf::Vector2f(m_oPosition.x, m_oPosition.y + m_dSpikeHeight));
m_oTriangle.setPoint(2, sf::Vector2f(m_oPosition.x + m_dSpikeHeight, m_oPosition.y + m_dSpikeHeight));
m_oTriangle.setFillColor(sf::Color(m_dStartingColor, m_dStartingColor, m_dStartingColor));
m_oTriangle.setOutlineThickness(1);
m_dLeft = m_oPosition.x - m_oTriangle.getLocalBounds().width;
m_dRight = m_oPosition.x + m_oTriangle.getLocalBounds().width;
}
Spike::~Spike() {}
void Spike::Draw(sf::RenderWindow &a_oWindow) {
a_oWindow.draw(m_oTriangle);
}
float Spike::GetLeft() {
return m_dLeft;
}
float Spike::GetRight() {
return m_dRight;
}
void Spike::SetFillColor(sf::Color &a_oColor) {
m_oTriangle.setFillColor(a_oColor);
}
void Spike::ResetFillColor() {
m_oTriangle.setFillColor(sf::Color(m_dDefaultColor, m_dDefaultColor, m_dDefaultColor));
}
void Spike::Fade() {
if (m_oTriangle.getFillColor() == m_oEndColor)
return;
m_dStartingColor += 0.5;
m_oTriangle.setFillColor(sf::Color(m_dStartingColor, m_dStartingColor, m_dStartingColor));
}