diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-13 10:42:55 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-01-13 10:42:55 -0500 |
commit | f91e95eed85bdd74b219b20a435fa6f297069da1 (patch) | |
tree | bb22c40e618932c3aaef5b8d62e7305d4895a998 /src | |
parent | 620311fb15953984c2fe37917d678f9b3aaa00b6 (diff) |
vector2 stuff, other things
Diffstat (limited to 'src')
-rw-r--r-- | src/components.cpp | 6 | ||||
-rw-r--r-- | src/gametime.cpp | 24 | ||||
-rw-r--r-- | src/inventory.cpp | 8 | ||||
-rw-r--r-- | src/old/entities.cpp.bak (renamed from src/entities.cpp.bak) | 0 | ||||
-rw-r--r-- | src/old/inventory.cpp.bak (renamed from src/inventory.cpp.bak) | 0 | ||||
-rw-r--r-- | src/old/items.cpp.bak (renamed from src/items.cpp.bak) | 0 | ||||
-rw-r--r-- | src/old/mob.cpp.bak (renamed from src/mob.cpp.bak) | 0 | ||||
-rw-r--r-- | src/old/quest.cpp.bak (renamed from src/quest.cpp.bak) | 0 | ||||
-rw-r--r-- | src/texture.cpp | 4 | ||||
-rw-r--r-- | src/ui.cpp | 4 | ||||
-rw-r--r-- | src/world.cpp | 18 |
11 files changed, 31 insertions, 33 deletions
diff --git a/src/components.cpp b/src/components.cpp index 28a81fe..b758cb6 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -306,12 +306,12 @@ std::vector<Frame> developFrame(XMLElement* xml) std::string sname = sxml->Name(); if (sname == "src") { foffset = (sxml->Attribute("offset") != nullptr) ? - str2coord(sxml->Attribute("offset")) : vec2(0,0); + sxml->StrAttribute("offset") : vec2(0,0); fdraw = (sxml->Attribute("drawOffset") != nullptr) ? - str2coord(sxml->Attribute("drawOffset")) : vec2(0,0); + sxml->StrAttribute("drawOffset") : vec2(0,0); if (sxml->Attribute("size") != nullptr) { - fsize = str2coord(sxml->Attribute("size")); + fsize = sxml->Attribute("size"); tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), foffset, fsize), fdraw)); } else { tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), foffset), fdraw)); diff --git a/src/gametime.cpp b/src/gametime.cpp index 1005d84..cb736ff 100644 --- a/src/gametime.cpp +++ b/src/gametime.cpp @@ -1,15 +1,9 @@ #include <gametime.hpp> -#include <common.hpp> +#include <common.hpp> // millis static unsigned int tickCount = 0; -static float deltaTime = 1; - -// millisecond timers -static unsigned int currentTime = 0; -static unsigned int prevTime; - -static float accum = 0.0f; +static unsigned int deltaTime = 1; namespace game { namespace time { @@ -34,15 +28,19 @@ namespace game { } void mainLoopHandler(void) { - if (!currentTime) - currentTime = prevTime = millis(); + static unsigned int cur = 0, prev; - currentTime = millis(); - deltaTime = currentTime - prevTime; - prevTime = currentTime; + if (cur == 0) + cur = prev = millis(); + + cur = millis(); + deltaTime = cur - prev; + prev = cur; } bool tickHasPassed(void) { + static unsigned int accum = 0; + accum += deltaTime; if (accum > MSEC_PER_TICK) { accum = 0.0f; diff --git a/src/inventory.cpp b/src/inventory.cpp index 480c803..ed6028b 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -2,10 +2,10 @@ #include <common.hpp> #include <events.hpp> -#include <texture.hpp> -#include <render.hpp> +//#include <texture.hpp> +//#include <render.hpp> -constexpr const char* ICON_TEX_FILE_PATH = "config/invIcons.txt"; +constexpr const char* iconTexturePath = "config/invIcons.txt"; static std::vector<Texture> iconTextures; @@ -16,7 +16,7 @@ void InventorySystem::configure(entityx::EventManager &ev) void InventorySystem::loadIcons(void) { iconTextures.clear(); - auto icons = readFileA(ICON_TEX_FILE_PATH); + auto icons = readFileA(iconTexturePath); for (const auto& s : icons) iconTextures.push_back(s); } diff --git a/src/entities.cpp.bak b/src/old/entities.cpp.bak index 25dd379..25dd379 100644 --- a/src/entities.cpp.bak +++ b/src/old/entities.cpp.bak diff --git a/src/inventory.cpp.bak b/src/old/inventory.cpp.bak index 1b325c0..1b325c0 100644 --- a/src/inventory.cpp.bak +++ b/src/old/inventory.cpp.bak diff --git a/src/items.cpp.bak b/src/old/items.cpp.bak index 180c5fa..180c5fa 100644 --- a/src/items.cpp.bak +++ b/src/old/items.cpp.bak diff --git a/src/mob.cpp.bak b/src/old/mob.cpp.bak index e78e5cd..e78e5cd 100644 --- a/src/mob.cpp.bak +++ b/src/old/mob.cpp.bak diff --git a/src/quest.cpp.bak b/src/old/quest.cpp.bak index f19359e..f19359e 100644 --- a/src/quest.cpp.bak +++ b/src/old/quest.cpp.bak diff --git a/src/texture.cpp b/src/texture.cpp index b47c3c7..721e5cb 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -10,6 +10,10 @@ namespace Colors ColorTex red; ColorTex blue; + GLfloat texCoord[12] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + void init(void) { white = ColorTex(Color(255, 255, 255)); black = ColorTex(Color(0, 0, 0 )); @@ -650,8 +650,8 @@ namespace ui { auto stride = 5 * sizeof(GLfloat); // we always want to make sure c1 is lower left and c2 is upper right - if (c1.x > c2.x) c1.swapX(c2); // std::swap(c1.x, c2.y); - if (c1.y > c2.y) c1.swapY(c2); // std::swap(c1.y, c2.y); + if (c1.x > c2.x) std::swap(c1.x, c2.x); + if (c1.y > c2.y) std::swap(c1.y, c2.y); // if the box is too small, we will not be able to draw it if (c2.x - c1.x < (boxCornerDim.x) || c2.y - c1.y < (boxCornerDim.y)) diff --git a/src/world.cpp b/src/world.cpp index 6551442..8f4be8e 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -324,9 +324,9 @@ void WorldSystem::load(const std::string& file) vec2 coords; if (wxml->Attribute("position") != nullptr) { - coords = str2coord(wxml->StrAttribute("position")); + coords = wxml->StrAttribute("position"); } else { - coords = str2coord(abcd->StrAttribute("value")); + coords = abcd->StrAttribute("value"); } float cdat[2] = {coords.x, coords.y}; @@ -345,7 +345,7 @@ void WorldSystem::load(const std::string& file) vec2 dim; if (abcd->Attribute("value") != nullptr) - dim = str2coord(abcd->StrAttribute("value")); + dim = abcd->StrAttribute("value"); else dim = entity.component<Sprite>()->getSpriteSize(); @@ -355,9 +355,9 @@ void WorldSystem::load(const std::string& file) vec2 dir; if (wxml->Attribute("direction") != nullptr) { - dir = str2coord(wxml->StrAttribute("direction")); + dir = wxml->StrAttribute("direction"); } else if (wxml->Attribute("value") != nullptr) { - dir = str2coord(wxml->StrAttribute("value")); + dir = wxml->StrAttribute("value"); } else { dir = vec2(0,0); } @@ -669,9 +669,8 @@ void WorldSystem::render(void) const auto SCREEN_WIDTH = game::SCREEN_WIDTH; const auto SCREEN_HEIGHT = game::SCREEN_HEIGHT; - const ivec2 backgroundOffset = ivec2 { - static_cast<int>(SCREEN_WIDTH) / 2, static_cast<int>(SCREEN_HEIGHT) / 2 - }; + const vector2<int> backgroundOffset + (static_cast<int>(SCREEN_WIDTH) / 2, static_cast<int>(SCREEN_HEIGHT) / 2); int iStart, iEnd, pOffset; @@ -1179,8 +1178,6 @@ void WorldSystem::detect(entityx::TimeDelta dt) void WorldSystem::goWorldRight(Position& p, Solid &d) { if (!(world.toRight.empty()) && (p.x + d.width > world.startX * -1 - HLINES(5))) { - auto& rs = *game::engine.getSystem<RenderSystem>(); - //rs.fadeLock(); ui::toggleBlack(); ui::waitForCover(); while (waitToSwap) @@ -1188,7 +1185,6 @@ void WorldSystem::goWorldRight(Position& p, Solid &d) load(world.toRight); game::engine.getSystem<PlayerSystem>()->setX(world.startX + HLINES(10)); ui::toggleBlack(); - //rs.unfade(); } } |