X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.cpp;h=048ec263a4c56be5a779e90e793a0c6602044022;hb=4c12267c6727caa3522ac5e38b4f8c17d544ef3e;hp=76ded2db2c9b15bc35ba637bf5567ccdfee369d4;hpb=7cf057b5b3a28c3896af27cb725fbf0b4f1459c2;p=orbi.git diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 76ded2d..048ec26 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; } @@ -193,30 +197,48 @@ void Application::RenderEntities() { constexpr Color boundsColor(0xFA, 0x00, 0x00); constexpr Color vboxColor(0xFA, 0xFA, 0x00); constexpr Color hboxColor(0x00, 0xFA, 0x00); + constexpr Color dotColor(0x00, 0xFA, 0xFA); - 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.LeftTop()), + cam.ToScale(e->bounds.Size()) ); + if (const Character *c = dynamic_cast(e)) { + if (c->orient == Entity::LOOKS_LEFT) { + canvas.OutlineRectRot( + Rect( + cam.ToScreen(c->bounds.LeftTop() + c->arm.LeftTop()), + cam.ToScale(c->arm.Size()) + ), + cam.ToScreen(c->bounds.LeftTop() + c->armOrigin), + c->armAngle + ); + //canvas.SetColor(dotColor); + //canvas.Cross(cam.ToScreen(c->bounds.LeftTop() + c->armOrigin), 5); + } else { + canvas.OutlineRectRot( + Rect( + cam.ToScreen(c->bounds.RightTop() + MirrorY(c->arm.RightTop())), + cam.ToScale(c->arm.Size()) + ), + cam.ToScreen(c->bounds.RightTop() + MirrorY(c->armOrigin)), + -c->armAngle + ); + //canvas.SetColor(dotColor); + //canvas.Cross(cam.ToScreen(c->bounds.RightTop() + MirrorY(c->armOrigin)), 5); + } + } canvas.SetColor(vboxColor); - canvas.Line( - cam.ToScreen(Vector(e.vbox.Left(), e.vbox.Top())), - cam.ToScreen(Vector(e.vbox.Right(), e.vbox.Top())) - Vector(1, 0) - ); - canvas.Line( - cam.ToScreen(Vector(e.vbox.Left(), e.vbox.Bottom())) - Vector(0, 1), - cam.ToScreen(Vector(e.vbox.Right(), e.vbox.Bottom())) - Vector(1, 1) + canvas.OutlineRect( + cam.ToScreen(e->vbox.LeftTop()), + 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())) - Vector(0, 1) - ); - canvas.Line( - cam.ToScreen(Vector(e.hbox.Right(), e.hbox.Top())) - Vector(1, 0), - cam.ToScreen(Vector(e.hbox.Right(), e.hbox.Bottom())) - Vector(1, 1) + canvas.OutlineRect( + cam.ToScreen(e->hbox.LeftTop()), + cam.ToScale(e->hbox.Size()) ); } }