diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-15 14:42:40 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-15 14:42:40 +0200 |
commit | 6319b7c8bf1689c990f8849c76e1871bcea9584d (patch) | |
tree | eacc4f3284897bd93468627a6f00981128e16755 /Canvas.cpp | |
parent | ee2aedc27eeb8c0c50bf662dfa3a2dcdcdb3ff91 (diff) |
use C++-style structs and move tile XY to tile.data
Diffstat (limited to 'Canvas.cpp')
-rw-r--r-- | Canvas.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -13,13 +13,11 @@ 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 data) { - size_t index = this->pos_to_index(x, y); +void Canvas::set_tile(TileData data) { + size_t index = this->pos_to_index(data.x, data.y); if (this->tiles[index] != nullptr) delete this->tiles[index]; this->tiles[index] = new Tile(this->museum, data); - this->tiles[index]->x = x; - this->tiles[index]->y = y; } size_t Canvas::pos_to_index(unsigned x, unsigned y) { @@ -39,7 +37,10 @@ void Canvas::set_data(CanvasData data) { for (size_t x = 0; x < this->data.columns; x++) { if (this->tiles[this->pos_to_index(x, y)] != nullptr) continue; - this->set_tile(x, y, {}); + this->set_tile({ + .x = static_cast<unsigned int>(x), + .y = static_cast<unsigned int>(y), + }); } } } |