|
@@ -12,7 +12,7 @@ bool Debuggers::GamePlay(float fElapsedTime)
|
12
|
12
|
DrawSprite(0, 0, &backgroundSprite);
|
13
|
13
|
|
14
|
14
|
uint32_t bugsSize = bugs.size();
|
15
|
|
- auto aliveBugs = std::count_if(bugs.begin(), bugs.end(), [](Bug* bug) { return bug->IsActive() && bug->IsAlive(); });
|
|
15
|
+ int aliveBugs = std::count_if(bugs.begin(), bugs.end(), [](Bug* bug) { return bug->IsActive() && bug->IsAlive(); });
|
16
|
16
|
|
17
|
17
|
Programmer* player = programmers.front();
|
18
|
18
|
|
|
@@ -27,14 +27,16 @@ bool Debuggers::GamePlay(float fElapsedTime)
|
27
|
27
|
bugsCatchedByPlayer++;
|
28
|
28
|
}
|
29
|
29
|
SpawnBugParticles(bug);
|
30
|
|
- bug->Kill();
|
31
|
30
|
if (state == STATE_GAME)
|
32
|
31
|
olc::SOUND::PlaySample(bugCatchSample);
|
|
32
|
+
|
|
33
|
+ bug->Kill();
|
33
|
34
|
SpawnBug();
|
34
|
35
|
}
|
35
|
36
|
}
|
36
|
37
|
} else if (bug->IsAlive()) {
|
37
|
38
|
bugsMissed++;
|
|
39
|
+ bug->Kill();
|
38
|
40
|
SpawnBug();
|
39
|
41
|
if (state == STATE_GAME) {
|
40
|
42
|
sourceCode.erase(sourceCode.begin());
|
|
@@ -59,20 +61,20 @@ bool Debuggers::GamePlay(float fElapsedTime)
|
59
|
61
|
if (player->Collides(bonus)) {
|
60
|
62
|
auto type = bonus->GetType();
|
61
|
63
|
if (type == BONUS_DOCUMENTATION) {
|
62
|
|
- if (aliveBugs > 1) {
|
63
|
|
- for (auto& bug : bugs) {
|
64
|
|
- if (bug->IsAlive() && bug->IsActive()) {
|
65
|
|
- SpawnBugParticles(bug);
|
66
|
|
- bug->Kill();
|
67
|
|
- break;
|
68
|
|
- }
|
|
64
|
+ auto count = std::max(aliveBugs / 10, 1);
|
|
65
|
+ for (auto& bug : bugs) {
|
|
66
|
+ SpawnBugParticles(bug);
|
|
67
|
+ bug->Kill();
|
|
68
|
+ count--;
|
|
69
|
+ if (count <= 0) {
|
|
70
|
+ break;
|
69
|
71
|
}
|
70
|
72
|
}
|
71
|
73
|
} else {
|
72
|
74
|
bonusesCatched[type]++;
|
73
|
75
|
}
|
74
|
76
|
bonus->Kill();
|
75
|
|
- // TODO play pickup sound
|
|
77
|
+ olc::SOUND::PlaySample(bonusSample);
|
76
|
78
|
}
|
77
|
79
|
} else {
|
78
|
80
|
bonus->Kill();
|
|
@@ -99,11 +101,11 @@ bool Debuggers::GamePlay(float fElapsedTime)
|
99
|
101
|
SpawnProgrammer();
|
100
|
102
|
}
|
101
|
103
|
|
102
|
|
- if (bugsCatched > 12 * bugsSize) {
|
|
104
|
+ if (bugsCatched > 14 * bugsSize) {
|
103
|
105
|
SpawnBug();
|
104
|
106
|
}
|
105
|
107
|
|
106
|
|
- if (GetRandom<float>() < 0.01 * fElapsedTime) {
|
|
108
|
+ if (GetRandom<float>() < 0.03 * fElapsedTime) {
|
107
|
109
|
SpawnBonus();
|
108
|
110
|
}
|
109
|
111
|
|