X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.cpp;h=94901bfd44df41c8f431931f8049132c5ea40a2a;hb=a8523bee4fc349a800f5f6d67b470c3a801beaa9;hp=cbfafd374537935625dbaad63955d4d7edacbcd6;hpb=dbc08d84d9de1a77cba0dd97e4701f4ac99d056e;p=orbi.git diff --git a/src/app/Application.cpp b/src/app/Application.cpp index cbfafd3..94901bf 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -148,15 +148,15 @@ void Application::OnKeyUp(const SDL_KeyboardEvent &e) { void Application::Update(int dt) { const float delta = dt / 1e3; - ctrl.Update(delta); + for (int i = 0; i < dt; ++i) { + ctrl.Update(1e-3); + world.Update(1e-3); + } target.Update(delta); focus = ctrl.Controlling() - ? ctrl.Controlled().bounds.Center() + ? ctrl.Controlled().vbox.Center() : target.Pos(); cam.Update(delta); - for (int i = 0; i < dt; ++i) { - world.Update(1e-3); - } } @@ -169,9 +169,13 @@ void Application::Render() { void Application::RenderBackground() { constexpr Color background(0x00, 0x00, 0x00); + constexpr Color outlineColor(0x00, 0x00, 0xFA); canvas.SetColor(background); canvas.Fill(); + + canvas.SetColor(outlineColor); + canvas.Grid(cam.ToScreen(Vector(0, 0)), cam.ToScale(world.Size()), cam.ToScale(Vector(1, 1))); } void Application::RenderWorld() { @@ -186,23 +190,34 @@ void Application::RenderWorld() { } void Application::RenderEntities() { - constexpr Color entityColor(0x00, 0xFA, 0x00); - canvas.SetColor(entityColor); + constexpr Color vboxColor(0xFA, 0x00, 0x00); + constexpr Color hboxColor(0x00, 0xFA, 0x00); for (const Entity &e : world.Entities()) { - const Vector pos(e.bounds.Left(), e.bounds.Top()); - const Vector size(e.bounds.Size()); - canvas.OutlineRect(cam.ToScreen(pos), cam.ToScale(size)); + canvas.SetColor(vboxColor); + canvas.Line( + cam.ToScreen(Vector(e.vbox.Left(), e.vbox.Top())), + cam.ToScreen(Vector(e.vbox.Right(), e.vbox.Top())) + ); + canvas.Line( + cam.ToScreen(Vector(e.vbox.Left(), e.vbox.Bottom())), + cam.ToScreen(Vector(e.vbox.Right(), e.vbox.Bottom())) + ); + canvas.SetColor(hboxColor); + canvas.Line( + cam.ToScreen(Vector(e.hbox.Left(), e.hbox.Top())), + cam.ToScreen(Vector(e.hbox.Left(), e.hbox.Bottom())) + ); + canvas.Line( + cam.ToScreen(Vector(e.hbox.Right(), e.hbox.Top())), + cam.ToScreen(Vector(e.hbox.Right(), e.hbox.Bottom())) + ); } } void Application::RenderUI() { - constexpr Color outlineColor(0x00, 0x00, 0xFA); constexpr Color targetColor(0xFA, 0xFA, 0x00); - canvas.SetColor(outlineColor); - canvas.Grid(cam.ToScreen(Vector(0, 0)), cam.ToScale(world.Size()), cam.ToScale(Vector(1, 1))); - canvas.SetColor(targetColor); canvas.Cross(cam.ToScreen(target.Pos()), 15); }