From: Clyne Sullivan Date: Thu, 22 Dec 2016 02:40:05 +0000 (-0500) Subject: Merge branch 'master' of https://github.com/tcsullivan/gamedev X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=ae9ceadaa184f5e9775135ae264c8bbffd4efa9d;p=clyne%2Fgamedev.git Merge branch 'master' of https://github.com/tcsullivan/gamedev --- ae9ceadaa184f5e9775135ae264c8bbffd4efa9d diff --cc include/engine.hpp index 6e0c5a0,d4028d8..52569e7 --- a/include/engine.hpp +++ b/include/engine.hpp @@@ -38,11 -71,29 +71,24 @@@ public namespace game { + /** + * Handles all game events. + */ extern entityx::EventManager events; + + /** + * Handles entity data. + */ extern entityx::EntityManager entities; - /** - * Handles sprite loading, for the sprite system. - */ - extern SpriteLoader sprite_l; - + /** + * An instance of the main game engine. + */ extern Engine engine; + /** + * Ends the game. + */ inline void endGame(void) { events.emit(); } diff --cc src/components.cpp index 8a66f80,e85883e..f95f46f --- a/src/components.cpp +++ b/src/components.cpp @@@ -90,12 -98,9 +98,8 @@@ void RenderSystem::update(entityx::Enti 1.0, 1.0, 1.0, 0.0}; - if (entity.has_component()) { - sprite.sprite = entity.component().get()->nextFrame(); - } - for (auto &S : sprite.sprite) { - float width = HLINES(S.first.size.x); - float height = HLINES(S.first.size.y); + const auto& size = S.first.tex.getDim() * game::HLINE; vec2 loc = vec2(pos.x + S.first.offset.x, pos.y + S.first.offset.y); @@@ -267,10 -275,9 +274,8 @@@ std::vector developFrame(XMLElem auto sxml = framexml->FirstChildElement(); while (sxml) { std::string sname = sxml->Name(); -- if (sname == "src") { ++ if (sname == "src") tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), vec2(0,0)), vec2(0,0))); - //std::cout << tmpf.back().first.pic << std::endl; -- } sxml = sxml->NextSiblingElement(); } tmp.push_back(tmpf); diff --cc src/ui.cpp index e87c74a,0b22e34..a154d7e --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -1093,19 -1027,25 +1023,22 @@@ namespace ui return; } - auto ftc = Color(0, 0, 0, fadeIntensity); - if (fadeWhite) - ftc.red = ftc.green = ftc.blue = 255; - - auto fadeTex = Texture::genColor(ftc); + ColorTex fadeTex (fadeWhite ? Color(255, 255, 255, fadeIntensity) : + Color(0, 0, 0, fadeIntensity)); + static const GLfloat tex[] = { + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0 + }; - GLfloat tex[] = {0.0, 0.0, - 1.0, 0.0, - 0.0, 1.0, - 1.0, 1.0}; - - GLfloat backdrop[] = {offset.x - SCREEN_WIDTH / 2 - 1, offset.y - SCREEN_HEIGHT / 2, -7.9, - offset.x + SCREEN_WIDTH / 2, offset.y - SCREEN_HEIGHT / 2, -7.9, - offset.x - SCREEN_WIDTH / 2 - 1, offset.y + SCREEN_HEIGHT / 2, -7.9, - offset.x + SCREEN_WIDTH / 2, offset.y + SCREEN_HEIGHT / 2, -7.9}; + GLfloat backdrop[] = { + offset.x - SCREEN_WIDTH2 - 1, offset.y - SCREEN_HEIGHT2, -7.9, + offset.x + SCREEN_WIDTH2, offset.y - SCREEN_HEIGHT2, -7.9, + offset.x - SCREEN_WIDTH2 - 1, offset.y + SCREEN_HEIGHT2, -7.9, + offset.x + SCREEN_WIDTH2, offset.y + SCREEN_HEIGHT2, -7.9 + }; setFontZ(-8.2); glUniform1i(Render::textShader.uniform[WU_texture], 0); diff --cc src/world.cpp index 059b6c7,df005e4..c458ab0 --- a/src/world.cpp +++ b/src/world.cpp @@@ -1042,20 -1043,24 +1044,23 @@@ void WorldSystem::render(void // the ending pixel of the world static const float e = static_cast(SCREEN_WIDTH) / 2.0f; - static const auto blackTex = Texture::genColor(Color(0, 0, 0)); static const float sheight = static_cast(SCREEN_HEIGHT); + if (offset.x + world.startX > s) { - glBindTexture(GL_TEXTURE_2D, blackTex); + Colors::black.use(); glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f); + auto off = offset.y - static_cast(SCREEN_HEIGHT) / 2.0f; + GLfloat blackBarLeft[] = { - s, 0.0f, -3.5f, 0.0f, 0.0f, - world.startX, 0.0f, -3.5f, 1.0f, 0.0f, - world.startX, sheight, -3.5f, 1.0f, 1.0f, + s, 0.0f + off, -3.5f, 0.0f, 0.0f, + world.startX, 0.0f + off, -3.5f, 1.0f, 0.0f, + world.startX, sheight + off, -3.5f, 1.0f, 1.0f, - world.startX, sheight, -3.5f, 1.0f, 1.0f, - s, sheight, -3.5f, 0.0f, 1.0f, - s, 0.0f, -3.5f, 0.0f, 0.0f + world.startX, sheight + off, -3.5f, 1.0f, 1.0f, + s, sheight + off, -3.5f, 0.0f, 1.0f, + s, 0.0f + off, -3.5f, 0.0f, 0.0f }; glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, &blackBarLeft[0]); @@@ -1064,17 -1069,19 +1069,19 @@@ } if (offset.x - world.startX < e) { - glBindTexture(GL_TEXTURE_2D, blackTex); + Colors::black.use(); glUniform1f(Render::worldShader.uniform[WU_light_impact], 0.0f); + + auto off = offset.y - static_cast(SCREEN_HEIGHT) / 2.0f; GLfloat blackBarRight[] = { - -(world.startX), 0.0f, -3.5f, 0.0f, 0.0f, - e, 0.0f, -3.5f, 1.0f, 0.0f, - e, sheight, -3.5f, 1.0f, 1.0f, + -(world.startX), 0.0f + off, -3.5f, 0.0f, 0.0f, + e, 0.0f + off, -3.5f, 1.0f, 0.0f, + e, sheight + off, -3.5f, 1.0f, 1.0f, - e, sheight, -3.5f, 1.0f, 1.0f, - -(world.startX), sheight, -3.5f, 0.0f, 1.0f, - -(world.startX), 0.0f, -3.5f, 0.0f, 0.0f + e, sheight + off, -3.5f, 1.0f, 1.0f, + -(world.startX), sheight + off, -3.5f, 0.0f, 1.0f, + -(world.startX), 0.0f + off, -3.5f, 0.0f, 0.0f }; glVertexAttribPointer(Render::worldShader.coord, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 5, &blackBarRight[0]);