summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kurator/src/Battle.cpp19
-rw-r--r--kurator/src/components.h5
2 files changed, 15 insertions, 9 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index da4e34a..28c24c1 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -53,11 +53,11 @@ Battle::update(const float dt)
if (timer.left < 0.0)
registry.destroy(entity);
}
- auto pops = registry.view<PopMove, battles::Transform>();
- for (auto&& [entity, pop, transform] : pops.each()) {
+ auto pops = registry.view<PopMove, UIOffset>();
+ for (auto&& [entity, pop, offset] : pops.each()) {
const auto speed = pop.speed.scale(dt);
- transform.position.x += speed.x;
- transform.position.y += speed.y;
+ offset.x += speed.x;
+ offset.y += speed.y;
const auto damp = pop.speed.scale(pop.damp).scale(dt);
pop.speed.x -= damp.x;
pop.speed.y -= damp.y;
@@ -83,10 +83,10 @@ Battle::draw() const
DrawLine(x, y, x + marker.radius*std::cos(transform.angle), y + marker.radius*std::sin(transform.angle), WHITE);
DrawText(marker.name.c_str(), x+10, y-10, 20.0f, GRAY);
}
- auto pops = registry.view<CenteredText, battles::Transform>();
- for (const auto& [entity, text, transform] : pops.each()) {
- const int x = width/2 + transform.position.x*scale - text.width/2;
- const int y = height/2 + transform.position.y*scale - text.font_size/2;
+ auto pops = registry.view<CenteredText, battles::Transform, UIOffset>();
+ for (const auto& [entity, text, transform, offset] : pops.each()) {
+ const int x = width/2 + transform.position.x*scale - text.width/2 + offset.x;
+ const int y = height/2 + transform.position.y*scale - text.font_size/2 + offset.y;
DrawText(text.text.c_str(), x, y, text.font_size, text.color);
}
auto points = registry.view<battles::HitPoints, battles::Team>();
@@ -116,7 +116,8 @@ Battle::receive(const battles::Hit& hit)
registry.emplace<Timed>(entity, 1.2);
registry.emplace<CenteredText>(entity, text, MeasureText(text.c_str(), 10), 10, RED);
registry.emplace<battles::Transform>(entity, transform.position, 0.0);
- registry.emplace<PopMove>(entity, battles::Point{0.0, -0.6}, 0.998);
+ registry.emplace<UIOffset>(entity, 0, 0);
+ registry.emplace<PopMove>(entity, battles::Point{0.0, -20}, 0.9998);
}
diff --git a/kurator/src/components.h b/kurator/src/components.h
index 6e03412..5a6a43e 100644
--- a/kurator/src/components.h
+++ b/kurator/src/components.h
@@ -26,6 +26,11 @@ struct CenteredText
};
+struct UIOffset : public battles::Point
+{
+};
+
+
struct PopMove
{
battles::Point speed;