aboutsummaryrefslogtreecommitdiff
path: root/YellowTileBehavior.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'YellowTileBehavior.cpp')
-rw-r--r--YellowTileBehavior.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/YellowTileBehavior.cpp b/YellowTileBehavior.cpp
index 4e0b7f1..5697aab 100644
--- a/YellowTileBehavior.cpp
+++ b/YellowTileBehavior.cpp
@@ -19,8 +19,11 @@ uniform_int_distribution<int> random_bool(0, 1);
uniform_real_distribution<float> random_float(-1, 1);
void YellowTileBehavior::update(Tile & tile) {
- this->steps_total += this->steps;
- for (unsigned int i = 0; i < this->steps; i++) {
+ unsigned int new_artists = this->interactions - this->last_interactions;
+ this->last_interactions = this->interactions;
+
+ for (unsigned int i = 0; i < new_artists; i++) {
+ if (i >= 2) break;
ArtistData new_data = {
.x = static_cast<float>(tile.x),
.y = static_cast<float>(tile.y),
@@ -29,13 +32,11 @@ void YellowTileBehavior::update(Tile & tile) {
random_bool(rng) ? new_data.vx = velocity : new_data.vy = velocity;
this->museum->people.add_artist(new_data);
}
- this->steps = 0;
- if (this->steps_total >= 2) {
- TileData new_data = tile.data;
- new_data.type = "G";
- tile.set_data(new_data);
- }
+ if (this->interactions < 2) return;
+ TileData new_data = tile.data;
+ new_data.type = "G";
+ tile.set_data(new_data);
}
unique_ptr<TileBehaviorStrategy> YellowTileBehavior::clone(Museum & museum) {