From b3a54e9b149ae2df289d6719b02972ff3694ee21 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 25 Oct 2024 18:03:24 +0200 Subject: fix mementos implementation --- Artist.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Artist.cpp') diff --git a/Artist.cpp b/Artist.cpp index 7bcd04b..9a9ac8e 100644 --- a/Artist.cpp +++ b/Artist.cpp @@ -5,10 +5,10 @@ using namespace std; +static constexpr const float velocity_scale = 0.2; + Artist::Artist(Museum & museum, ArtistData data) : museum(museum) { this->data = data; - this->data.vx /= 5; - this->data.vy /= 5; } void Artist::update(bool tick) { @@ -22,8 +22,8 @@ void Artist::update(bool tick) { } void Artist::update_edge_collision() { - float next_x = this->data.x + this->data.vx; - float next_y = this->data.y + this->data.vy; + float next_x = this->data.x + this->data.vx * velocity_scale; + float next_y = this->data.y + this->data.vy * velocity_scale; // +0.5 is for own size (the assignment explicitly defines the x,y position // of artists as the top-left corner) @@ -37,8 +37,8 @@ void Artist::update_movement() { float last_x = this->data.x; float last_y = this->data.y; - this->data.x += this->data.vx; - this->data.y += this->data.vy; + this->data.x += this->data.vx * velocity_scale; + this->data.y += this->data.vy * velocity_scale; if (abs(int(last_x) - int(this->data.x)) > 0) this->step = true; if (abs(int(last_y) - int(this->data.y)) > 0) this->step = true; -- cgit v1.2.3