aboutsummaryrefslogtreecommitdiff
path: root/StepTileCommand.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 16:37:02 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 16:37:02 +0200
commit4cb7ca42003c177e3acc80075d7594e555966106 (patch)
treed2f5836d70a1fa2dc1d18c4fb59f1bf1f2f91f5a /StepTileCommand.cpp
parentd8289105193707daede1a5b59137f18e20f20aeb (diff)
fix command design pattern
Diffstat (limited to 'StepTileCommand.cpp')
-rw-r--r--StepTileCommand.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/StepTileCommand.cpp b/StepTileCommand.cpp
index ff5c6b2..cc7d62d 100644
--- a/StepTileCommand.cpp
+++ b/StepTileCommand.cpp
@@ -1,11 +1,18 @@
#include "StepTileCommand.h"
-#include "Museum.h"
+#include "Canvas.h"
-void StepTileCommand::execute(unsigned int x, unsigned int y) {
- Museum & museum = this->get_museum();
- if (x >= museum.canvas.data.columns) return;
- if (y >= museum.canvas.data.rows) return;
- Tile & tile = museum.canvas.get_tile(x, y);
+using namespace std;
+
+StepTileCommand::StepTileCommand(Canvas & c, pair<unsigned int, unsigned int> tile) : canvas(c) {
+ this->x = tile.first;
+ this->y = tile.second;
+}
+
+void StepTileCommand::execute() {
+ Canvas & canvas = this->canvas;
+ if (this->x >= canvas.data.columns) return;
+ if (this->y >= canvas.data.rows) return;
+ Tile & tile = canvas.get_tile(this->x, this->y);
tile.step(nullptr);
tile.update();
}