diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
commit | 1e0a52b03fe655d7073ef20703dbb2e7646f74d3 (patch) | |
tree | f1709c2e9565d78c791653e71e6a4b26b3138423 /ViewController.cpp | |
parent | 277157b3e06b2deeacbdbc8bf6190de19f88169d (diff) |
add XY struct for 2d points and offsets
Diffstat (limited to 'ViewController.cpp')
-rw-r--r-- | ViewController.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ViewController.cpp b/ViewController.cpp index 67fd77c..40e624a 100644 --- a/ViewController.cpp +++ b/ViewController.cpp @@ -39,9 +39,9 @@ void ViewController::update_size() { } void ViewController::update_tiles() { - for (unsigned y = 0; y < this->museum.canvas.data.rows; y++) { - for (unsigned x = 0; x < this->museum.canvas.data.columns; x++) { - Tile & tile = this->museum.canvas.get_tile(x, y); + for (int y = 0; y < this->museum.canvas.data.rows; y++) { + for (int x = 0; x < this->museum.canvas.data.columns; x++) { + Tile & tile = this->museum.canvas.get_tile({ x, y }); Rectangle rect = { .x = static_cast<float>(x * scale), .y = static_cast<float>(y * scale), @@ -66,10 +66,10 @@ void ViewController::update_artists() { } } -void ViewController::draw_pathfinding_dot(pair<unsigned int, unsigned int> point, const Color & color) { +void ViewController::draw_pathfinding_dot(const XY & point, const Color & color) { this->view.fill_rect(center({ - .x = static_cast<float>(point.first * scale), - .y = static_cast<float>(point.second * scale), + .x = static_cast<float>(point.x * scale), + .y = static_cast<float>(point.y * scale), .width = static_cast<float>(pathfinding_size), .height = static_cast<float>(pathfinding_size), }), color); @@ -177,8 +177,8 @@ void ViewController::ev_mousedown(MouseCode button) { void ViewController::ev_mousemove(unsigned x, unsigned y) { this->mouse_pos = { - static_cast<float>(x) / static_cast<float>(this->scale), - static_cast<float>(y) / static_cast<float>(this->scale), + .x = static_cast<int>(x / this->scale), + .y = static_cast<int>(y / this->scale), }; } |