diff options
Diffstat (limited to 'kurator/src/Controller.cpp')
-rw-r--r-- | kurator/src/Controller.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/kurator/src/Controller.cpp b/kurator/src/Controller.cpp new file mode 100644 index 0000000..d7efcdb --- /dev/null +++ b/kurator/src/Controller.cpp @@ -0,0 +1,42 @@ +#include "Controller.h" + +#include <raylib.h> + +#include <kurator/sim/State.h> + +#include "Mouse.h" + + +namespace kurator +{ + + +void Controller::update(sim::State& ctx) +{ + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) { + const auto delta = GetMouseDelta(); + ctx.camera.offset.x -= delta.x / ctx.camera.scale; + ctx.camera.offset.y -= delta.y / ctx.camera.scale; + } + mouse.update(); + inspect.show(); +} + + +void Controller::draw(const sim::State&) const +{ + if (mouse.is_dragging()) { + const auto pos = mouse.position(); + const auto start = mouse.start(); + const auto diff = start - pos; + DrawRectangleLines( + std::min(pos.x, start.x), + std::min(pos.y, start.y), + std::abs(diff.x), + std::abs(diff.y), + GRAY); + } +} + + +} // namespace kurator |