From 5ab49aa46b6f1a9cd5196165009d2ee08b6b7a87 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 13 Oct 2024 19:06:52 +0200 Subject: implement all tile behaviors --- BlueTileBehavior.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'BlueTileBehavior.cpp') diff --git a/BlueTileBehavior.cpp b/BlueTileBehavior.cpp index ca714a4..fbca527 100644 --- a/BlueTileBehavior.cpp +++ b/BlueTileBehavior.cpp @@ -1,12 +1,39 @@ #include #include "BlueTileBehavior.h" +#include "Artist.h" +#include "Tile.h" +#include "TileData.h" using namespace std; BlueTileBehavior BlueTileBehavior::instance {"B"}; -void BlueTileBehavior::update(Tile &) { +void BlueTileBehavior::step(Artist & artist) { + this->interactions++; + if (this->interactions > 1) return; + + if (artist.data.vx == 0) dx = 1; + if (artist.data.vy == 0) dy = 1; +} + +void BlueTileBehavior::update_neighbor(Tile * tile) { + if (tile == nullptr) return; + + TileData new_data = tile->data; + new_data.type = "B"; + tile->set_data(new_data); +} + +void BlueTileBehavior::update(Tile & tile) { + if (this->interactions < 1) return; + + this->update_neighbor(tile.get_neighbor(this->dx, this->dy)); + this->update_neighbor(tile.get_neighbor(-this->dx, -this->dy)); + + TileData new_data = tile.data; + new_data.type = "Y"; + tile.set_data(new_data); } unique_ptr BlueTileBehavior::clone(Museum & museum) { -- cgit v1.2.3