|
@@ -19,7 +19,14 @@
|
|
|
#include "Player.hpp"
|
|
|
#include <thread>
|
|
|
|
|
|
-IngameState::IngameState(): State(), _player(), _paused(false), _blurSize(0.f), _frameAlpha(0.f) {}
|
|
|
+IngameState::IngameState(): State(), _player(), _paused(false), _blurSize(0.f), _frameAlpha(0.f), _wormhole() {}
|
|
|
+
|
|
|
+IngameState::~IngameState()
|
|
|
+{
|
|
|
+ Echo::debug("Flushing state");
|
|
|
+ _lightSystem.removeLight(_light);
|
|
|
+ _lightSystem.removeLight(_wormhole.light());
|
|
|
+}
|
|
|
|
|
|
Rect Player::getBounds()
|
|
|
{
|
|
@@ -72,6 +79,9 @@ void IngameState::init()
|
|
|
_marioSound.setBuffer(_context->assets->loadSound("data/audio/Mario.ogg"));
|
|
|
_wasted.setTexture(_context->assets->loadTexture("data/background/Wasted.png"));
|
|
|
|
|
|
+ _wormhole.load(_context->assets->loadTexture("data/triangle/Wormhole.png"), _context->assets->loadTexture("data/triangle/Wormhole_light.png"));
|
|
|
+ _wormhole.setPosition(400.f, 400.f);
|
|
|
+
|
|
|
// Global window is not initialized yet in this method. If you need _context->window->getSize(), go to refresh() instead.
|
|
|
|
|
|
_status = State::Ongoing;
|
|
@@ -97,6 +107,7 @@ void IngameState::refresh()
|
|
|
_lightSystem.create(sf::FloatRect{{0.f, 0.f}, {0.f, 0.f}}, {_context->window->getSize().x, _context->window->getSize().y}, _penumbraTexture, _unshadowShader, _lightOverShapeShader, _normalsShader);
|
|
|
_lightSystem.normalsEnabled(true);
|
|
|
_lightSystem.addLight(_light);
|
|
|
+ _lightSystem.addLight(_wormhole.light());
|
|
|
}
|
|
|
|
|
|
void IngameState::coreThink(const sf::Event& event)
|
|
@@ -156,6 +167,8 @@ void IngameState::coreUpdate(sf::Time delta)
|
|
|
_paused = true;
|
|
|
_marioSound.play();
|
|
|
}
|
|
|
+
|
|
|
+ _wormhole.update(delta);
|
|
|
}
|
|
|
void IngameState::coreRender(const bool shaders)
|
|
|
{
|
|
@@ -201,6 +214,7 @@ void IngameState::coreRender(const bool shaders)
|
|
|
|
|
|
_foreground.renderNormals(false);
|
|
|
_context->window->draw(_foreground);
|
|
|
+ _context->window->draw(_wormhole);
|
|
|
_context->window->draw(_player);
|
|
|
|
|
|
|