aboutsummaryrefslogtreecommitdiff
path: root/Artist.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-25 13:02:38 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-25 13:02:38 +0200
commit8cf389aaf748c77aecda0b3a3773c45053b0f231 (patch)
tree91268879710d6ae2868e548d3f44c664a19443d8 /Artist.cpp
parentda669db4f083194bc78358041c5d9929e103ac9f (diff)
implement all ALGA features
Diffstat (limited to 'Artist.cpp')
-rw-r--r--Artist.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/Artist.cpp b/Artist.cpp
index 6d95542..7bcd04b 100644
--- a/Artist.cpp
+++ b/Artist.cpp
@@ -3,15 +3,21 @@
#include "Artist.h"
#include "Museum.h"
+using namespace std;
+
Artist::Artist(Museum & museum, ArtistData data) : museum(museum) {
this->data = data;
this->data.vx /= 5;
this->data.vy /= 5;
}
-void Artist::update() {
- this->update_edge_collision();
- this->update_movement();
+void Artist::update(bool tick) {
+ if (tick) {
+ this->update_edge_collision();
+ this->update_movement();
+ }
+ // Artist<->Artist collisions are marked by CollisionChecker
+ this->update_path_collision();
this->update_color();
}
@@ -38,6 +44,17 @@ void Artist::update_movement() {
if (abs(int(last_y) - int(this->data.y)) > 0) this->step = true;
}
+void Artist::update_path_collision() {
+ PathfindingContext & ctx = this->museum.pathfinding;
+ if (!ctx.has_collision) return;
+ Pathfinder & solver = ctx.get_solver();
+ bool is_solution = solver.is_solution({
+ static_cast<int>(this->data.x),
+ static_cast<int>(this->data.y),
+ });
+ if (is_solution) this->colliding = true;
+}
+
void Artist::update_color() {
if (this->colliding) {
this->color = {