aboutsummaryrefslogtreecommitdiff
path: root/Canvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Canvas.cpp')
-rw-r--r--Canvas.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Canvas.cpp b/Canvas.cpp
new file mode 100644
index 0000000..63dbe74
--- /dev/null
+++ b/Canvas.cpp
@@ -0,0 +1,14 @@
+#include "Canvas.h"
+
+Tile & Canvas::get_tile(unsigned x, unsigned y) {
+ return this->tiles[this->pos_to_index(x, y)];
+}
+
+void Canvas::set_tile(unsigned x, unsigned y, TileData t) {
+ this->tiles[this->pos_to_index(x, y)] = Tile(t);
+}
+
+size_t Canvas::pos_to_index(unsigned x, unsigned y) {
+ return y * this->data.columns + x;
+}
+