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);
- }
}
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<int>(0, 0)), cam.ToScale(world.Size()), cam.ToScale(world.TileSize()));
}
void Application::RenderWorld() {
}
void Application::RenderEntities() {
- constexpr Color entityColor(0x00, 0xFA, 0x00);
- canvas.SetColor(entityColor);
+ constexpr Color boundsColor(0xFA, 0x00, 0x00);
+ constexpr Color vboxColor(0xFA, 0xFA, 0x00);
+ constexpr Color hboxColor(0x00, 0xFA, 0x00);
for (const Entity &e : world.Entities()) {
- const Vector<float> pos(e.bounds.Left(), e.bounds.Top());
- const Vector<float> size(e.bounds.Size());
- canvas.OutlineRect(cam.ToScreen(pos), cam.ToScale(size));
+ canvas.SetColor(boundsColor);
+ canvas.OutlineRect(
+ cam.ToScreen(Vector<float>(e.bounds.Left(), e.bounds.Top())),
+ cam.ToScale(Vector<float>(e.bounds.Size()))
+ );
+ canvas.SetColor(vboxColor);
+ canvas.Line(
+ cam.ToScreen(Vector<float>(e.vbox.Left(), e.vbox.Top())),
+ cam.ToScreen(Vector<float>(e.vbox.Right(), e.vbox.Top())) - Vector<int>(1, 0)
+ );
+ canvas.Line(
+ cam.ToScreen(Vector<float>(e.vbox.Left(), e.vbox.Bottom())) - Vector<int>(0, 1),
+ cam.ToScreen(Vector<float>(e.vbox.Right(), e.vbox.Bottom())) - Vector<int>(1, 1)
+ );
+ canvas.SetColor(hboxColor);
+ canvas.Line(
+ cam.ToScreen(Vector<float>(e.hbox.Left(), e.hbox.Top())),
+ cam.ToScreen(Vector<float>(e.hbox.Left(), e.hbox.Bottom())) - Vector<int>(0, 1)
+ );
+ canvas.Line(
+ cam.ToScreen(Vector<float>(e.hbox.Right(), e.hbox.Top())) - Vector<int>(1, 0),
+ cam.ToScreen(Vector<float>(e.hbox.Right(), e.hbox.Bottom())) - Vector<int>(1, 1)
+ );
}
}
void Application::RenderUI() {
- constexpr Color outlineColor(0x00, 0x00, 0xFA);
constexpr Color targetColor(0xFA, 0xFA, 0x00);
- canvas.SetColor(outlineColor);
- canvas.Grid(cam.ToScreen(Vector<int>(0, 0)), cam.ToScale(world.Size()), cam.ToScale(Vector<float>(1, 1)));
-
canvas.SetColor(targetColor);
canvas.Cross(cam.ToScreen(target.Pos()), 15);
}