-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpecialEffects.cpp
More file actions
executable file
·60 lines (53 loc) · 1.25 KB
/
SpecialEffects.cpp
File metadata and controls
executable file
·60 lines (53 loc) · 1.25 KB
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
#include "include/globals.hpp"
#include "include/SpecialEffects.hpp"
SpecialEffects::SpecialEffects()
{
}
void SpecialEffects::Update()
{
for(std::vector<FxBlock *>::iterator it = sparks.begin(); it != sparks.end(); ++it)
{
(*it)->Update(0.01);
}
for(std::vector<FxBlock *>::iterator it = sparks.begin(); it != sparks.end(); ++it)
{
if ((*it)->y > SCREEN_HEIGHT)
{
delete *it;
sparks.erase(it);
break;
}
}
}
void SpecialEffects::Render(sf::RenderWindow &window)
{
sf::RectangleShape tile;
tile.setSize(sf::Vector2f(6, 6));
for(std::vector<FxBlock *>::iterator it = sparks.begin(); it != sparks.end(); ++it)
{
if (rand() % 2)
{
tile.setFillColor(Color(35, 181, 69));
}
else
{
tile.setFillColor(Color(38, 38, 38));
}
tile.setPosition((*it)->x, (*it)->y);
window.draw(tile);
}
}
void SpecialEffects::SpawnEffect(int x, int y, int number)
{
if (sparks.size() <= 30)
{
for (int i = 0; i < number; i++)
{
FxBlock *newBlock = new FxBlock(x, y);
sparks.push_back(newBlock);
}
}
}
SpecialEffects::~SpecialEffects()
{
}