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()) {
canvas.SetColor(boundsColor);
canvas.OutlineRect(
- cam.ToScreen(e->bounds.Position()),
+ cam.ToScreen(e->bounds.LeftTop()),
cam.ToScale(e->bounds.Size())
);
if (const Character *c = dynamic_cast<const Character *>(e)) {
- canvas.OutlineRectRot(
- Rect<float>(
- cam.ToScreen(c->bounds.Position() + c->arm.Position()),
- cam.ToScale(c->arm.Size())
- ),
- cam.ToScreen(c->bounds.Position() + c->armOrigin),
- c->armAngle
- );
+ if (c->orient == Entity::LOOKS_LEFT) {
+ canvas.OutlineRectRot(
+ Rect<float>(
+ 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<float>(
+ 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.OutlineRect(
- cam.ToScreen(e->vbox.Position()),
+ cam.ToScreen(e->vbox.LeftTop()),
cam.ToScale(e->vbox.Size())
);
canvas.SetColor(hboxColor);
canvas.OutlineRect(
- cam.ToScreen(e->hbox.Position()),
+ cam.ToScreen(e->hbox.LeftTop()),
cam.ToScale(e->hbox.Size())
);
}
return v / Length(v);
}
+template<class Scalar>
+constexpr Vector<Scalar> MirrorX(Vector<Scalar> v) {
+ return Vector<Scalar>(v.x, -v.y);
+}
+template<class Scalar>
+constexpr Vector<Scalar> MirrorY(Vector<Scalar> v) {
+ return Vector<Scalar>(-v.x, v.y);
+}
+
template<class Scalar>
constexpr Vector<Scalar> Rotate90(Vector<Scalar> v) {
return Vector<Scalar>(-v.y, v.x);
float Right() const { return rb.x; }
float Bottom() const { return rb.y; }
- Vector<float> Position() const { return lt; }
+ Vector<float> LeftTop() const { return lt; }
+ Vector<float> LeftBottom() const { return Vector<float>(lt.x, rb.y); }
+ Vector<float> RightTop() const { return Vector<float>(rb.x, lt.y); }
+ Vector<float> RightBottom() const { return rb; }
+
Vector<float> Center() const { return lt + HalfSize(); }
Vector<float> HalfSize() const { return Size() / 2.0f; }
Vector<float> Size() const { return size; }