#include "ViewController.h" #include "View.h" #include "Museum.h" ViewController::ViewController(Museum & m) : museum(m) {}; void ViewController::update(View & view) { this->update_size(view); this->update_tiles(view); this->update_artists(view); } void ViewController::update_size(View & view) { view.set_size( this->scale * this->museum.canvas.data.columns, this->scale * this->museum.canvas.data.rows ); } void ViewController::update_tiles(View & view) { 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); Rectangle rect = { .x = x * scale, .y = y * scale, .width = scale - line_width, .height = scale - line_width, }; view.draw_rect(rect, tile.color); } } } void ViewController::update_artists(View & view) { People & people = this->museum.people; for (Artist * artist : people.get_artists()) { Rectangle rect = { .x = static_cast(artist->data.x * scale), .y = static_cast(artist->data.y * scale), .width = artist_size, .height = artist_size, }; view.draw_rect(rect, artist->color); } }