]> git.localhorst.tv Git - space.git/commitdiff
split render function master
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 9 Jan 2014 07:15:14 +0000 (08:15 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 9 Jan 2014 07:15:14 +0000 (08:15 +0100)
src/app/Application.cpp
src/app/Application.h

index 9f78eaeb592b2660d7a9264cbe748dfc4004148e..6a217666015bb228f9588e1214dd6e92a4063a2f 100644 (file)
@@ -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<float>(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<float> direction = s.Dir();
                const Vector<int> 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);
 }
 
 }
index 17fdce8c84b77f7074477563dd67bf9eef203e8d..fa1d92f82887d7a280431b2715758d6c8abe3e8c 100644 (file)
@@ -34,6 +34,10 @@ private:
        void Update(int delta_ms);
 
        void Render();
+       void RenderBackground();
+       void RenderGrid();
+       void RenderShips();
+       void RenderUI();
 
 private:
        Canvas &canvas;