X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.cpp;h=3ddb41443a3d4bd6860603cd69a7e1073b670a87;hb=a73a6dd63407b5f5ef5b0c635551ad27b27c95d6;hp=44a71ccd7f5fddb33f06c0873c3228e2c1fd00d1;hpb=03b142b877e19a2355e1a79e279e024922d44655;p=orbi.git diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 44a71cc..3ddb414 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -2,6 +2,7 @@ #include "../graphics/Canvas.h" #include "../graphics/Color.h" +#include "../world/Character.h" #include "../world/Entity.h" #include "../world/Tileset.h" #include "../world/World.h" @@ -157,6 +158,9 @@ void Application::Update(int dt) { ? ctrl.Controlled().vbox.Center() : target.Pos(); cam.Update(delta); + + // testing arm rotation + //dynamic_cast(*world.Entities().begin())->armAngle -= 3 * delta; } @@ -175,7 +179,7 @@ void Application::RenderBackground() { canvas.Fill(); canvas.SetColor(outlineColor); - canvas.Grid(cam.ToScreen(Vector(0, 0)), cam.ToScale(world.Size()), cam.ToScale(Vector(1, 1))); + canvas.Grid(cam.ToScreen(Vector(0, 0)), cam.ToScale(world.Size()), cam.ToScale(world.TileSize())); } void Application::RenderWorld() { @@ -194,29 +198,31 @@ void Application::RenderEntities() { constexpr Color vboxColor(0xFA, 0xFA, 0x00); constexpr Color hboxColor(0x00, 0xFA, 0x00); - for (const Entity &e : world.Entities()) { + for (const Entity *e : world.Entities()) { canvas.SetColor(boundsColor); canvas.OutlineRect( - cam.ToScreen(Vector(e.bounds.Left(), e.bounds.Top())), - cam.ToScale(Vector(e.bounds.Size())) + cam.ToScreen(e->bounds.Position()), + cam.ToScale(e->bounds.Size()) ); + if (const Character *c = dynamic_cast(e)) { + canvas.OutlineRectRot( + Rect( + cam.ToScreen(c->bounds.Position() + c->arm.Position()), + cam.ToScale(c->arm.Size()) + ), + cam.ToScreen(c->bounds.Position() + c->armOrigin), + c->armAngle + ); + } 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.OutlineRect( + cam.ToScreen(e->vbox.Position()), + cam.ToScale(e->vbox.Size()) ); 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())) + canvas.OutlineRect( + cam.ToScreen(e->hbox.Position()), + cam.ToScale(e->hbox.Size()) ); } }