From: Daniel Karbach Date: Thu, 9 Jan 2014 07:15:14 +0000 (+0100) Subject: split render function X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;ds=sidebyside;p=space.git split render function --- diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 9f78eae..6a21766 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -189,14 +189,22 @@ void Application::Update(int dt) { void Application::Render() { + RenderBackground(); + RenderGrid(); + RenderShips(); + RenderUI(); +} + +void Application::RenderBackground() { constexpr Color background(0x00, 0x00, 0x00); - constexpr Color univGrid(0xEE, 0xEE, 0xEE); - constexpr Color secGrid(0x77, 0x77, 0x77); - constexpr Color entityColor(0x00, 0xAA, 0xAA); - constexpr Color focusColor(0xFA, 0xFA, 0x00); canvas.SetColor(background); canvas.Fill(); +} + +void Application::RenderGrid() { + constexpr Color univGrid(0xEE, 0xEE, 0xEE); + constexpr Color secGrid(0x77, 0x77, 0x77); canvas.Grid2( cam.ToScreen(Vector(0, 0)), @@ -205,11 +213,12 @@ void Application::Render() { univ.secSize, secGrid, univGrid); +} - canvas.SetColor(focusColor); - canvas.Cross(cam.ToScreen(focus.Pos()), 15); +void Application::RenderShips() { + constexpr Color shipColor(0x00, 0xAA, 0xAA); - canvas.SetColor(entityColor); + canvas.SetColor(shipColor); for (const Ship &s : univ.Ships()) { const Vector direction = s.Dir(); const Vector position = cam.ToScreen(s.pos); @@ -219,11 +228,18 @@ void Application::Render() { canvas.Line(position, nose); canvas.Quad(nose, left, position, right); } +} + +void Application::RenderUI() { + constexpr Color focusColor(0xFA, 0xFA, 0x00); autopilot.Render(canvas, cam); linGauge.Render(canvas, controlled->linThrottle); rotGauge.Render(canvas, controlled->rotThrottle); + + canvas.SetColor(focusColor); + canvas.Cross(cam.ToScreen(focus.Pos()), 15); } } diff --git a/src/app/Application.h b/src/app/Application.h index 17fdce8..fa1d92f 100644 --- a/src/app/Application.h +++ b/src/app/Application.h @@ -34,6 +34,10 @@ private: void Update(int delta_ms); void Render(); + void RenderBackground(); + void RenderGrid(); + void RenderShips(); + void RenderUI(); private: Canvas &canvas;