aboutsummaryrefslogtreecommitdiffstats
path: root/src/components.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-01-12 09:27:43 -0500
committerClyne Sullivan <tullivan99@gmail.com>2017-01-12 09:27:43 -0500
commit620311fb15953984c2fe37917d678f9b3aaa00b6 (patch)
tree98cf46c253228495245020e881a6e2edb6cb2644 /src/components.cpp
parentb018bfd5d69a51b352cc87cf92136a0b20712845 (diff)
fixes, main cleanup
Diffstat (limited to 'src/components.cpp')
-rw-r--r--src/components.cpp66
1 files changed, 5 insertions, 61 deletions
diff --git a/src/components.cpp b/src/components.cpp
index 4d80d25..28a81fe 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -72,49 +72,18 @@ Texture RenderSystem::loadTexture(const std::string& file)
return loadTexResult;
}
-void RenderSystem::fade(void)
+void RenderSystem::render(void)
{
- fadeIn = false, fadeIntensity = 0;
-}
-
-void RenderSystem::fadeLock(void)
-{
- fade();
- while (fadeIntensity < 1)
- std::this_thread::sleep_for(1ms);
-}
-
-void RenderSystem::unfade(void)
-{
- fadeIn = true, fadeIntensity = 1;
-}
-
-void RenderSystem::unfadeLock(void)
-{
- fade();
- while (fadeIntensity > 0)
- std::this_thread::sleep_for(1ms);
-}
-
-void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
-{
- (void)ev;
-
if (!loadTexString.empty()) {
loadTexResult = Texture(loadTexString);
loadTexString.clear();
}
-
- // update fade system
- if (fadeIn && fadeIntensity > 0)
- fadeIntensity -= 0.01f;
- else if(!fadeIn && fadeIntensity < 1)
- fadeIntensity += 0.01f;
Render::worldShader.use();
Render::worldShader.enable();
- en.each<Visible, Sprite, Position>([dt](entityx::Entity entity, Visible &visible, Sprite &sprite, Position &pos) {
+ game::entities.lock();
+ game::entities.each<Visible, Sprite, Position>([](entityx::Entity entity, Visible &visible, Sprite &sprite, Position &pos) {
// Verticies and shit
float its = 0;
@@ -179,38 +148,13 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
Render::worldShader.disable();
Render::worldShader.unuse();
- en.each<Visible, Position, Solid, Name>([](entityx::Entity e, Visible &v, Position &pos, Solid& dim, Name &name) {
+ game::entities.each<Visible, Position, Solid, Name>([](entityx::Entity e, Visible &v, Position &pos, Solid& dim, Name &name) {
(void)e;
(void)v;
ui::setFontZ(-5.0);
ui::putStringCentered(pos.x + dim.width / 2, pos.y - ui::fontSize - HLINES(0.5), name.name);
});
-
- // draw fade
- static const GLfloat tex[8] = {
- 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- auto SCREEN_WIDTH2 = game::SCREEN_WIDTH / 2, SCREEN_HEIGHT2 = game::SCREEN_HEIGHT / 2;
- GLfloat coord[12] = {
- 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
- };
-
- Render::textShader.use();
- Render::textShader.enable();
-
- Colors::black.use();
- glUniform4f(Render::textShader.uniform[WU_tex_color], 1.0f, 1.0f, 1.0f, fadeIntensity);
- glUniform1i(Render::textShader.uniform[WU_texture], 0);
- glVertexAttribPointer(Render::textShader.coord, 3, GL_FLOAT, GL_FALSE, 0, coord);
- glVertexAttribPointer(Render::textShader.tex, 2, GL_FLOAT, GL_FALSE, 0, tex);
- glDrawArrays(GL_QUADS, 0, 4);
-
- Render::textShader.disable();
- Render::textShader.unuse();
+ game::entities.unlock();
}
void DialogSystem::configure(entityx::EventManager &ev)