-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPopulateEmitters.cpp
More file actions
48 lines (42 loc) · 1.12 KB
/
PopulateEmitters.cpp
File metadata and controls
48 lines (42 loc) · 1.12 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
#include "Engine.h"
using namespace sf;
using namespace std;
void Engine::populateEmitters(
vector <Vector2f>& vSoundEmitters,
int** arrayLevel)
{
// Make sure the vector is empty
vSoundEmitters.empty();
// Keep track of the previous emitter
// so we don't make too many
FloatRect previousEmitter;
// Search for fire in the level
for (int x = 0; x < (int)m_LM.getLevelSize().x; x++)
{
for (int y = 0; y < (int)m_LM.getLevelSize().y; y++)
{
if (arrayLevel[y][x] == 2)// fire is present
{
// Skip over any fire tiles too
// near a previous emitter
if (!FloatRect(x * TILE_SIZE,
y * TILE_SIZE,
TILE_SIZE,
TILE_SIZE).intersects(previousEmitter))
{
// Add the coordinates of this water block
vSoundEmitters.push_back(
Vector2f(x * TILE_SIZE, y * TILE_SIZE));
// Make a rectangle 6 blocks x 6 blocks,
// so we don't make any more emitters
// too close to this one
previousEmitter.left = x * TILE_SIZE;
previousEmitter.top = y * TILE_SIZE;
previousEmitter.width = TILE_SIZE * 6;
previousEmitter.height = TILE_SIZE * 6;
}
}
}
}
return;
}