]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
z standardization
authorClyne Sullivan <tullivan99@gmail.com>
Sat, 21 Oct 2017 14:08:41 +0000 (10:08 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sat, 21 Oct 2017 14:08:41 +0000 (10:08 -0400)
12 files changed:
include/inventory.hpp
include/render.hpp
include/ui_quest.hpp
src/attack.cpp
src/inventory.cpp
src/particle.cpp
src/player.cpp
src/render.cpp
src/systems/render.cpp
src/ui.cpp
src/ui_menu.cpp
src/world.cpp

index 273241a191d274d66c9475b4585c2861e9a0882e..753d90f7f4314d4cb7b1246ffbe564d942de4f1f 100644 (file)
@@ -76,7 +76,6 @@ private:
        constexpr static const char* itemsPath = "config/items.xml";
        constexpr static int entrySize = 70;
        constexpr static int hotbarSize = 4;
-       constexpr static float inventoryZ = -5.0f;
        constexpr static unsigned int rowSize = 8;
 
        static std::unordered_map<std::string, Item> itemList;
index a21fcdd9bb891ba7b4cb6eb436104adf67dccf65..e081b9d3a608f3c6700e4a6bf0e4452dd25c1845 100644 (file)
@@ -66,6 +66,22 @@ typedef enum {
 } WorldUniform;
 
 namespace Render {
+       namespace ZRange {
+               constexpr float World     =  9.9f;
+               constexpr float RenderSys =  5.0f;
+               constexpr float Ground    = -4.5f;
+               constexpr float Attack    = -5.0f;
+               constexpr float Particle  = -8.0f;
+               constexpr float Important = -8.5f;
+               constexpr float Inventory = -9.0f;
+               constexpr float Dialog    = -9.3f;
+               constexpr float Quest     = -9.5f;
+               constexpr float Fade      = -9.7f;
+               constexpr float Menu      = -9.8f;
+               constexpr float Mouse     = -9.89f;
+               constexpr float Debug     = -9.9f;
+       }
+
     extern Shader worldShader;
     extern Shader textShader;
 
index e06570aeafa1cd82025011736f0b1241a972960b..1c478caf9ec5ce0f53c01900e9aad7ab54b203dd 100644 (file)
@@ -30,12 +30,13 @@ namespace ui {
                void draw(void) {
                        if (!_toggle)
                                return;
-                       
+
+                       float z = Render::ZRange::Quest;
                        float top_y = offset.y + 200;
-                       ui::drawNiceBox(vec2 {offset.x - 200, top_y },
-                                       vec2 {offset.x + 200, offset.y - 200 },
-                                       -0.7f);
+                       ui::drawNiceBox(vec2 {offset.x - 200, top_y }, vec2 {offset.x + 200, offset.y - 200 },
+                               z);
 
+                       FontSystem::setFontZ(z - 0.01f);
                        UISystem::putStringCentered(vec2(offset.x, top_y - 40), "Current Quests:");
                        
                        const auto& titles = QuestSystem::getQuestTitles();
@@ -47,6 +48,7 @@ namespace ui {
                                //ui::putText(x + 40, y, q.desc.c_str());
                                //y -= 40; 
                        }
+                       FontSystem::setFontZ();
                }
        }
 }
index 8c5d44a870ab861876b910a9912d5591d5c85e1b..cf2f6277ec3c5315be4f5d6f290dd856a25b733c 100644 (file)
@@ -132,7 +132,7 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
 #define RATE 3
 void AttackSystem::render(void)
 {
-       float z = -9.9f;
+       float z = Render::ZRange::Attack;
        Render::worldShader.use();
        Render::worldShader.enable();
        for (auto& ae : effects) {
@@ -150,6 +150,7 @@ void AttackSystem::render(void)
                glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), verts);
                glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), verts + 3);
                glDrawArrays(GL_TRIANGLES, 0, 6);
+               z -= 0.05f;
        }
        Render::worldShader.disable();
        Render::worldShader.unuse();
index 947c7fc9bc02d9ffb518ba3172660cd0e771a0e2..1db8845e1b65df5f6303cecdc61b3737a3d88e30 100644 (file)
@@ -103,6 +103,7 @@ void InventorySystem::update(entityx::EntityManager &en, entityx::EventManager &
 
 void InventorySystem::render(void)
 {
+       float inventoryZ = Render::ZRange::Inventory;
        int size = items.size();
 
        // calculate positions
@@ -141,12 +142,12 @@ void InventorySystem::render(void)
                glUniform4f(Render::textShader.uniform[WU_tex_color], 1, 1, 1, .6);
                vec2 end = i.loc + entrySize - 6;
                GLfloat coords[] = {
-                       i.loc.x, i.loc.y, inventoryZ - 0.1, 0, 0,
-                       end.x,   i.loc.y, inventoryZ - 0.1, 0, 0,
-                       end.x,   end.y,   inventoryZ - 0.1, 0, 0,
-                       end.x,   end.y,   inventoryZ - 0.1, 0, 0,
-                       i.loc.x, end.y,   inventoryZ - 0.1, 0, 0,
-                       i.loc.x, i.loc.y, inventoryZ - 0.1, 0, 0,
+                       i.loc.x, i.loc.y, inventoryZ - 0.1f, 0, 0,
+                       end.x,   i.loc.y, inventoryZ - 0.1f, 0, 0,
+                       end.x,   end.y,   inventoryZ - 0.1f, 0, 0,
+                       end.x,   end.y,   inventoryZ - 0.1f, 0, 0,
+                       i.loc.x, end.y,   inventoryZ - 0.1f, 0, 0,
+                       i.loc.x, i.loc.y, inventoryZ - 0.1f, 0, 0,
                };
 
                glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), coords);
@@ -170,12 +171,12 @@ void InventorySystem::render(void)
                        vec2 end = (n == movingItem) ? ui::mouse + truDim / 2 : loc + truDim;
 
                        GLfloat coords[] = {
-                               sta.x, sta.y, inventoryZ - 0.2, 0, 1,
-                               end.x, sta.y, inventoryZ - 0.2, 1, 1,
-                               end.x, end.y, inventoryZ - 0.2, 1, 0,
-                               end.x, end.y, inventoryZ - 0.2, 1, 0,
-                               sta.x, end.y, inventoryZ - 0.2, 0, 0,
-                               sta.x, sta.y, inventoryZ - 0.2, 0, 1,
+                               sta.x, sta.y, inventoryZ - 0.2f, 0, 1,
+                               end.x, sta.y, inventoryZ - 0.2f, 1, 1,
+                               end.x, end.y, inventoryZ - 0.2f, 1, 0,
+                               end.x, end.y, inventoryZ - 0.2f, 1, 0,
+                               sta.x, end.y, inventoryZ - 0.2f, 0, 0,
+                               sta.x, sta.y, inventoryZ - 0.2f, 0, 1,
                        };
 
                        glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), coords);
@@ -183,9 +184,9 @@ void InventorySystem::render(void)
                        if (n == movingItem)
                                glUniform4f(Render::textShader.uniform[WU_tex_color], .8, .8, 1, .8);
                        glDrawArrays(GL_TRIANGLES, 0, 6);
-                       FontSystem::setFontZ(inventoryZ - 0.3); // TODO fix z's
+                       FontSystem::setFontZ(inventoryZ - 0.3f);
                        UISystem::putString(i.loc, std::to_string(i.count));
-                       FontSystem::setFontZ(-6);
+                       FontSystem::setFontZ();
                        glUniform4f(Render::textShader.uniform[WU_tex_color], 1, 1, 1, 1);
                }
        }
@@ -201,13 +202,14 @@ void InventorySystem::render(void)
                vec2 sta (pos.x, pos.y);
                sta += i.item->drawOffset;
                vec2 end (sta + (i.item->sprite.getDim() * game::HLINE));
+               float z = Render::ZRange::Attack + 0.1f;
                GLfloat coords[] = {
-                       sta.x, sta.y, -8, 0, 1,
-                       end.x, sta.y, -8, 1, 1,
-                       end.x, end.y, -8, 1, 0,
-                       end.x, end.y, -8, 1, 0,
-                       sta.x, end.y, -8, 0, 0,
-                       sta.x, sta.y, -8, 0, 1,
+                       sta.x, sta.y, z, 0, 1,
+                       end.x, sta.y, z, 1, 1,
+                       end.x, end.y, z, 1, 0,
+                       end.x, end.y, z, 1, 0,
+                       sta.x, end.y, z, 0, 0,
+                       sta.x, sta.y, z, 0, 1,
                };
 
                glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), coords);
index 33030276d57e28a6c44377378cfb617c07ec52ca..d1a07a391ce0e5b3550818eb7b0ab906a021bdbe 100644 (file)
@@ -59,20 +59,22 @@ void ParticleSystem::render(void)
        auto vbobuf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
        UserAssert(vbobuf != nullptr, "Failed to map the particle VBO");
 
+       float z = Render::ZRange::Particle;
        for (unsigned int i = 0, offset = 0; i < parts.size(); i++, offset += entrySize) {
                const auto& p = parts[i];
                static const auto& hl = game::HLINE;
                GLfloat coords[30] = {
-                       p.location.x,      p.location.y,      -1, p.color.x, p.color.y,
-                       p.location.x,      p.location.y + hl, -1, p.color.x, p.color.y,
-                       p.location.x + hl, p.location.y + hl, -1, p.color.x, p.color.y,
-                       p.location.x + hl, p.location.y + hl, -1, p.color.x, p.color.y,
-                       p.location.x + hl, p.location.y,      -1, p.color.x, p.color.y,
-                       p.location.x,      p.location.y,      -1, p.color.x, p.color.y
+                       p.location.x,      p.location.y,      z, p.color.x, p.color.y,
+                       p.location.x,      p.location.y + hl, z, p.color.x, p.color.y,
+                       p.location.x + hl, p.location.y + hl, z, p.color.x, p.color.y,
+                       p.location.x + hl, p.location.y + hl, z, p.color.x, p.color.y,
+                       p.location.x + hl, p.location.y,      z, p.color.x, p.color.y,
+                       p.location.x,      p.location.y,      z, p.color.x, p.color.y
                };
 
                //glBufferSubData(GL_ARRAY_BUFFER, offset, entrySize, coords);
                std::memcpy(reinterpret_cast<void*>(reinterpret_cast<unsigned long long>(vbobuf) + offset), coords, entrySize);
+               z -= 0.0001;
        }
 
        UserAssert(glUnmapBuffer(GL_ARRAY_BUFFER) == GL_TRUE, "Failed to unmap the particle VBO");
index db343471db88cd05a28d1d6107b3be05f430c2ea..07cb1a06d1863fa8c5c9dc7d43133d8515c5d31e 100644 (file)
@@ -253,8 +253,11 @@ bool PlayerSystem::receive(const UseItemEvent& uie)
                                        e.component<Hit>()->effect = uie.attack->effect;
                        }
                } else if (uie.item->type == "Food") {
-                       player.component<Health>()->health = player.component<Health>()->maxHealth;
-                       InventorySystem::take(uie.item->name, 1);
+                       auto health = player.component<Health>();
+                       if (health->health < health->maxHealth) {
+                               health->health = health->maxHealth;
+                               InventorySystem::take(uie.item->name, 1);
+                       }
                }
 
                cool.store(false);
index b9a97702e8e18672faf7b25e15ccde5683c81b8a..85384cec6c467996510bc0189b9b7729e859b41f 100644 (file)
@@ -177,25 +177,26 @@ void render(const int& fps)
        preRender();
 
        WorldSystem::render();
-       ParticleSystem::render();
-       AttackSystem::render();
        RenderSystem::render();
+       AttackSystem::render();
+       ParticleSystem::render();
+       UISystem::render();
        InventorySystem::render();
+       ui::draw();
+       FontSystem::render();
 
        // draw the debug overlay if desired
        if (ui::debug) {
                auto pos = PlayerSystem::getPosition();
+               FontSystem::setFontZ(Render::ZRange::Debug);
                UISystem::putText(vec2(offset.x - game::SCREEN_WIDTH / 2, (offset.y + game::SCREEN_HEIGHT / 2) - FontSystem::getSize()),
                    "loc: %s\noffset: %s\nfps: %d\nticks: %d\npcount: %d\nxml: %s\nmem: %llukb (%d)",
                        pos.toString(2).c_str(), offset.toString(2).c_str(), fps,
                        game::time::getTickCount(), ParticleSystem::getCount(),
                        WorldSystem::getXMLFile().c_str(), getUsedMem() / 1024, balance
                        );
+               FontSystem::setFontZ();
        }
-
-       UISystem::render();
-       ui::draw();
-       FontSystem::render();
        
        WindowSystem::render();
 }
index f72832b41eac1eaefc0332781d54858498971adc..48cf18c395c93709c451ac4bad23b1bb71a369b3 100644 (file)
@@ -109,7 +109,7 @@ void RenderSystem::render(void)
                                }
                        }
 
-                       its-=.01;
+                       its -= 0.01f;
                }
                glUniformMatrix4fv(Render::worldShader.uniform[WU_transform], 1, GL_FALSE, glm::value_ptr(glm::mat4(1.0f)));
 
@@ -118,13 +118,14 @@ void RenderSystem::render(void)
                        auto& health = *entity.component<Health>();
                        width *= health.health / static_cast<float>(health.maxHealth);
 
+                       float Z = Render::ZRange::Ground - 0.3f;
                        GLfloat health_coord[] = {
-                               pos.x, pos.y, -9, 0, 0,
-                               pos.x + width, pos.y, -9, 0, 0,
-                               pos.x + width, pos.y - 5, -9, 0, 0,
-                               pos.x + width, pos.y - 5, -9, 0, 0,
-                               pos.x, pos.y - 5, -9, 0, 0,
-                               pos.x, pos.y, -9, 0, 0,
+                               pos.x, pos.y, Z, 0, 0,
+                               pos.x + width, pos.y, Z, 0, 0,
+                               pos.x + width, pos.y - 5, Z, 0, 0,
+                               pos.x + width, pos.y - 5, Z, 0, 0,
+                               pos.x, pos.y - 5, Z, 0, 0,
+                               pos.x, pos.y, Z, 0, 0,
                        };
 
                        Colors::red.use();
@@ -132,17 +133,17 @@ void RenderSystem::render(void)
                        glVertexAttribPointer(Render::worldShader.tex, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), health_coord + 3);
                        glDrawArrays(GL_TRIANGLES, 0, 6);
                }
+
+               if (entity.has_component<Name>()) {
+                       FontSystem::setFontZ(Render::ZRange::Ground - 0.3f);
+                       UISystem::putStringCentered(vec2(pos.x + entity.component<Solid>()->width / 2,
+                               pos.y - FontSystem::getSize() - HLINES(0.5)), entity.component<Name>()->name);
+               }
        });
 
+       FontSystem::setFontZ();
        Render::worldShader.disable();
        Render::worldShader.unuse();
-
-       game::entities.each<Visible, Position, Solid, Name>([](entityx::Entity e, Visible &v, Position &pos, Solid& dim, Name &name) {
-               (void)e;
-               (void)v;
-               FontSystem::setFontZ(-5.0f);
-               UISystem::putStringCentered(vec2(pos.x + dim.width / 2, pos.y - FontSystem::getSize() - HLINES(0.5)), name.name);
-       });
 }
 
 void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
index 8a2d64daa005b73ec78615f39622306b9fb3bb33..a1cd2d50a88d4fd2025c82a9ac0f9e96a2ee49b4 100644 (file)
@@ -342,14 +342,14 @@ namespace ui {
                quest::draw();
 
                if (pageTexReady) {
-
+                       float z = Render::ZRange::Important;
             GLfloat page_verts[] = {
-                               offset.x - 300, SCREEN_HEIGHT - 100, -6.0, 0, 0,
-                               offset.x + 300, SCREEN_HEIGHT - 100, -6.0, 1, 0,
-                               offset.x + 300, SCREEN_HEIGHT - 600, -6.0, 1, 1,
-                               offset.x + 300, SCREEN_HEIGHT - 600, -6.0, 1, 1,
-                               offset.x - 300, SCREEN_HEIGHT - 600, -6.0, 0, 1,
-                               offset.x - 300, SCREEN_HEIGHT - 100, -6.0, 0, 0,
+                               offset.x - 300, SCREEN_HEIGHT - 100, z, 0, 0,
+                               offset.x + 300, SCREEN_HEIGHT - 100, z, 1, 0,
+                               offset.x + 300, SCREEN_HEIGHT - 600, z, 1, 1,
+                               offset.x + 300, SCREEN_HEIGHT - 600, z, 1, 1,
+                               offset.x - 300, SCREEN_HEIGHT - 600, z, 0, 1,
+                               offset.x - 300, SCREEN_HEIGHT - 100, z, 0, 0,
                        };
 
             glActiveTexture(GL_TEXTURE0);
@@ -375,7 +375,7 @@ namespace ui {
                glActiveTexture(GL_TEXTURE0);
                mouseTex.use();
                Render::useShader(&Render::textShader);
-               Render::drawRect(vec2(ui::mouse.x, ui::mouse.y - 64), vec2(ui::mouse.x + 64, ui::mouse.y), -9.9);
+               Render::drawRect(vec2(ui::mouse.x, ui::mouse.y - 64), vec2(ui::mouse.x + 64, ui::mouse.y), Render::ZRange::Mouse);
                Render::textShader.unuse();
        }
 
@@ -758,13 +758,14 @@ void UISystem::render(void)
                vec2 p1 (offset.x - game::SCREEN_WIDTH / 2, offset.y - game::SCREEN_HEIGHT / 2);
                vec2 p2 (p1.x + game::SCREEN_WIDTH, p1.y + game::SCREEN_HEIGHT);
 
+               float z = Render::ZRange::Fade;
                GLfloat backdrop[] = {
-                       p1.x, p1.y, -7.9, 0, 0,
-                       p2.x, p1.y, -7.9, 0, 0, 
-                       p2.x, p2.y, -7.9, 0, 0,
-                       p2.x, p2.y, -7.9, 0, 0,
-                       p1.x, p2.y, -7.9, 0, 0,
-                       p1.x, p1.y, -7.9, 0, 0,
+                       p1.x, p1.y, z, 0, 0,
+                       p2.x, p1.y, z, 0, 0, 
+                       p2.x, p2.y, z, 0, 0,
+                       p2.x, p2.y, z, 0, 0,
+                       p1.x, p2.y, z, 0, 0,
+                       p1.x, p1.y, z, 0, 0,
                };
 
                Render::textShader.use();
@@ -778,13 +779,14 @@ void UISystem::render(void)
 
                Render::textShader.disable();
                Render::textShader.unuse();
-               //setFontZ(-8.0);
        }
 
        if (!dialogText.empty()) {
+               float z = Render::ZRange::Dialog;
                vec2 where (offset.x - 300, game::SCREEN_HEIGHT - 60);
-               ui::drawNiceBox(vec2(where.x - 10, where.y - 200), vec2(where.x + 620, where.y + 20), -5.5f);
-               FontSystem::setFontZ(-6.0f);
+               ui::drawNiceBox(vec2(where.x - 10, where.y - 200), vec2(where.x + 620, where.y + 20),
+                       z);
+               FontSystem::setFontZ(z - 0.1f);
                putString(where, ui::typeOut(dialogText), where.x + 600);
 
                if (!dialogOptions.empty()) {
@@ -807,9 +809,10 @@ void UISystem::render(void)
 
        if (!importantText.empty()) {
                FontSystem::setFontSize(FontSystem::SizeLarge);
-               FontSystem::setFontZ(-9.0f);
+               FontSystem::setFontZ(Render::ZRange::Fade - 0.05f);
                putStringCentered(vec2(offset.x, 400), ui::typeOut(importantText));
-               FontSystem::setFontZ(-6.0f);
                FontSystem::setFontSize(FontSystem::SizeSmall);
        }
+
+       FontSystem::setFontZ();
 }
index f0b2eeb238c0fccff49a407467643728d0bc2662..920166d4c131689bab6b6e9887b518533afc2dbd 100644 (file)
@@ -248,6 +248,8 @@ namespace ui {
                }
 
         void draw(void) {
+                       float z = Render::ZRange::Menu;
+
                        if (currentMenu == nullptr)
                                return;
 
@@ -258,7 +260,7 @@ namespace ui {
 
             game::config::update();
             FontSystem::setFontSize(FontSystem::SizeLarge);
-                       FontSystem::setFontZ(-9.0);
+                       FontSystem::setFontZ(z - 0.03f);
        
             mouse.x = ui::premouse.x+offset.x-(SCREEN_WIDTH/2);
             mouse.y = (offset.y+SCREEN_HEIGHT/2)-ui::premouse.y;
@@ -272,7 +274,7 @@ namespace ui {
 
                        back.use();
                        Render::drawRect(vec2(offset.x - SCREEN_WIDTH / 2 - 1, offset.y - (SCREEN_HEIGHT / 2)),
-                                        vec2(offset.x + SCREEN_WIDTH / 2, offset.y + (SCREEN_HEIGHT / 2)), -8.5);
+                           vec2(offset.x + SCREEN_WIDTH / 2, offset.y + (SCREEN_HEIGHT / 2)), z);
 
                        Render::textShader.unuse();
 
@@ -309,7 +311,7 @@ namespace ui {
                         }
                     }
 
-                                       ui::drawNiceBoxColor(loc, end, -8.6, Color(cMult, cMult, cMult, 1.0f));
+                                       ui::drawNiceBoxColor(loc, end, z - 0.01f, Color(cMult, cMult, cMult, 1.0f));
                     //draw the button text
                     UISystem::putStringCentered(vec2(loc.x + (m.dim.x / 2),
                        loc.y + (m.dim.y / 2) - (FontSystem::getSize() / 2)),
@@ -334,7 +336,7 @@ namespace ui {
                         m.slider.sliderLoc *= m.dim.x - sliderW;
                     }
 
-                                       ui::drawNiceBoxColor(loc, end, -8.6, Color(.5f, .5f, .5f, 1.0f));
+                                       ui::drawNiceBoxColor(loc, end, z - 0.02f, Color(.5f, .5f, .5f, 1.0f));
 
                     //test if mouse is inside of the slider's borders
                     if ((mouse.x >= loc.x && mouse.x <= end.x) && (mouse.y >= loc.y && mouse.y <= end.y)) {
@@ -375,7 +377,7 @@ namespace ui {
 
                        SDLReceiver::clicked = false;
             FontSystem::setFontSize(FontSystem::SizeSmall);
-                       FontSystem::setFontZ(-8.0);
+                       FontSystem::setFontZ();
         }
 
 
index dcbc707f7377a15243d2920aa1743bce34ec0a6d..b163979e19c5414ab3d43c4606025d703ebae9f2 100644 (file)
@@ -430,6 +430,8 @@ void WorldSystem::die(void)
 
 void WorldSystem::render(void)
 {
+       float z = Render::ZRange::World;
+
        static Color ambient;
 
        const auto SCREEN_WIDTH = game::SCREEN_WIDTH;
@@ -475,12 +477,12 @@ void WorldSystem::render(void)
                skyOffset++;
 
        GLfloat skyverts[] = {
-               offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 9.9f, 0, skyOffset,
-               offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, 9.9f, 1, skyOffset,
-               offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 9.9f, 1, skyOffset,
-               offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, 9.9f, 1, skyOffset,
-               offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, 9.9f, 0, skyOffset,
-               offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, 9.9f, 0, skyOffset,
+               offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, z, 0, skyOffset,
+               offset.x + backgroundOffset.x + 5, offset.y - backgroundOffset.y, z, 1, skyOffset,
+               offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, z, 1, skyOffset,
+               offset.x + backgroundOffset.x + 5, offset.y + backgroundOffset.y, z, 1, skyOffset,
+               offset.x - backgroundOffset.x - 5, offset.y + backgroundOffset.y, z, 0, skyOffset,
+               offset.x - backgroundOffset.x - 5, offset.y - backgroundOffset.y, z, 0, skyOffset,
        };
 
        // rendering!!
@@ -510,12 +512,12 @@ void WorldSystem::render(void)
 
                for (auto &s : stars) {
                        float data[30] = {
-                               s.x + xcoord, s.y, 9.7, 0, 0,
-                               s.x + xcoord + stardim, s.y, 9.7, 1, 0,
-                               s.x + xcoord + stardim, s.y + stardim, 9.7, 1, 1,
-                               s.x + xcoord + stardim, s.y + stardim, 9.7, 1, 1,
-                               s.x + xcoord, s.y + stardim, 9.7, 0, 1,
-                               s.x + xcoord, s.y, 9.7, 0, 0
+                               s.x + xcoord, s.y, z - 0.1f, 0, 0,
+                               s.x + xcoord + stardim, s.y, z - 0.1f, 1, 0,
+                               s.x + xcoord + stardim, s.y + stardim, z - 0.1f, 1, 1,
+                               s.x + xcoord + stardim, s.y + stardim, z - 0.1f, 1, 1,
+                               s.x + xcoord, s.y + stardim, z - 0.1f, 0, 1,
+                               s.x + xcoord, s.y, z - 0.1f, 0, 0
                        };
 
                        std::memcpy(si, data, sizeof(float) * 30);
@@ -538,7 +540,7 @@ void WorldSystem::render(void)
        float parallax = 0.85f;
        float parallaxChange = 0.75f / layerCount;
 
-       float z = 8.0f;
+       z -= 0.2f;
        for (int i = 0; i < layerCount; i++, z -= 0.1f, parallax -= parallaxChange) {
                bgTex++;
                auto mountainDim = bgTex.getTextureDim() * game::HLINE;
@@ -578,12 +580,12 @@ void WorldSystem::render(void)
                world.indoorTex.use();
                auto dim = world.indoorTex.getDim() * game::HLINE;
                GLfloat verts[] = {
-                       world.startX,         GROUND_HEIGHT_MINIMUM,         z - 0.1f, 0, 0,
-                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM,         z - 0.1f, 1, 0,
-                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM + dim.y, z - 0.1f, 1, 1,
-                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM + dim.y, z - 0.1f, 1, 1,
-                       world.startX,         GROUND_HEIGHT_MINIMUM + dim.y, z - 0.1f, 0, 1,
-                       world.startX,         GROUND_HEIGHT_MINIMUM,         z - 0.1f, 0, 0,
+                       world.startX,         GROUND_HEIGHT_MINIMUM,         z, 0, 0,
+                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM,         z, 1, 0,
+                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM + dim.y, z, 1, 1,
+                       world.startX + dim.x, GROUND_HEIGHT_MINIMUM + dim.y, z, 1, 1,
+                       world.startX,         GROUND_HEIGHT_MINIMUM + dim.y, z, 0, 1,
+                       world.startX,         GROUND_HEIGHT_MINIMUM,         z, 0, 0,
                };
 
                glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), verts);
@@ -608,6 +610,7 @@ void WorldSystem::render(void)
        waitToSwap = true;
 
        bgTex++;
+       z = Render::ZRange::Ground;
 
        static std::vector<GLfloat> dirt;
        if (dirt.size() != world.data.size() * 30) {
@@ -626,7 +629,7 @@ void WorldSystem::render(void)
 
                int ty = world.data[i].groundHeight / 64 + world.data[i].groundColor;
                GLfloat five[5] = {
-                       0, 0, world.startX + HLINES(i), world.data[i].groundHeight - GRASS_HEIGHT, -4
+                       0, 0, world.startX + HLINES(i), world.data[i].groundHeight - GRASS_HEIGHT, z - 0.1f
                };
 
                push5(dirtp, five);
@@ -677,7 +680,7 @@ void WorldSystem::render(void)
                        // actually draw the grass.
                        if (wd.groundHeight) {
                                float five[5] = {
-                                       0, 1, world.startX + HLINES(i), wd.groundHeight + gh[0], -3
+                                       0, 1, world.startX + HLINES(i), wd.groundHeight + gh[0], z - 0.2f
                                };
 
                                push5(grassp, five);
@@ -724,12 +727,12 @@ void WorldSystem::render(void)
                        
                auto yOffset = offset.y - static_cast<float>(SCREEN_HEIGHT) / 2.0f;
                GLfloat blackBar[] = {
-                       s,            yOffset,           -3.5f, 0.0f, 0.0f,
-                       world.startX, yOffset,           -3.5f, 1.0f, 0.0f,
-                       world.startX, yOffset + sheight, -3.5f, 1.0f, 1.0f,
-                       world.startX, yOffset + sheight, -3.5f, 1.0f, 1.0f,
-                       s,            yOffset + sheight, -3.5f, 0.0f, 1.0f,
-                       s,            yOffset,           -3.5f, 0.0f, 0.0f
+                       s,            yOffset,           z - 0.3f, 0.0f, 0.0f,
+                       world.startX, yOffset,           z - 0.3f, 1.0f, 0.0f,
+                       world.startX, yOffset + sheight, z - 0.3f, 1.0f, 1.0f,
+                       world.startX, yOffset + sheight, z - 0.3f, 1.0f, 1.0f,
+                       s,            yOffset + sheight, z - 0.3f, 0.0f, 1.0f,
+                       s,            yOffset,           z - 0.3f, 0.0f, 0.0f
                };
 
                if (offset.x + world.startX > s) {
@@ -758,7 +761,7 @@ void WorldSystem::render(void)
                Render::worldShader.use();
                Colors::red.use();
                vec2 ll = vec2 {world.startX, GROUND_HEIGHT_MINIMUM};
-               Render::drawRect(ll, ll + vec2(world.indoorTex.getDim().x, 4), -3);
+               Render::drawRect(ll, ll + vec2(world.indoorTex.getDim().x, 4), z - 1);
                Render::worldShader.unuse();
        }