Browse Source

Sunday update

POSITIVE-MENTAL-ATTITUDE 8 years ago
parent
commit
86861b5c87

+ 4 - 5
Bullet.cpp

@@ -29,6 +29,7 @@ Bullet::Bullet(float rotation, sf::Vector2f initialPosition, sf::SoundBuffer& bu
 	_vertex[3].position = sf::Vector2f(-3.f, -40.f);
 	_vertex[3].position = sf::Vector2f(-3.f, -40.f);
 	_sound.setBuffer(buffer1);
 	_sound.setBuffer(buffer1);
 	_explosion.setBuffer(buffer2);
 	_explosion.setBuffer(buffer2);
+	_sound.setPlayingOffset(sf::Time::Zero);
 	_sound.play();
 	_sound.play();
 	genCollisionBox("data/hitbox/Bullet.png", sf::Vector2f(3.f, 40.f));
 	genCollisionBox("data/hitbox/Bullet.png", sf::Vector2f(3.f, 40.f));
 }
 }
@@ -103,7 +104,7 @@ void Bullet::destroyPixels(int& k, int x, int y)
 	}
 	}
 }
 }
 
 
-void Bullet::update(sf::Time delta)
+void Bullet::update(sf::Time delta, sf::Vector2f position)
 {
 {
 	float seconds = delta.asSeconds();
 	float seconds = delta.asSeconds();
 	const double degree = 3.14159265358 / 180.;
 	const double degree = 3.14159265358 / 180.;
@@ -127,13 +128,11 @@ void Bullet::update(sf::Time delta)
 				_hit = true;
 				_hit = true;
 			}
 			}
 	}
 	}
-	if(_hit and _sound.getStatus() == sf::Sound::Status::Stopped and _explosion.getStatus() == sf::Sound::Status::Stopped)
-	{
+	if(_hit && _sound.getStatus() == sf::Sound::Status::Stopped && _sound.getPlayingOffset() == sf::Time::Zero && _explosion.getStatus() == sf::Sound::Status::Stopped)
 		_dead = true;
 		_dead = true;
-	}
 }
 }
 
 
 const bool Bullet::isDead() const
 const bool Bullet::isDead() const
 {
 {
-	return _dead;
+	return _dead && _hit ? true : false;
 }
 }

+ 1 - 1
Bullet.hpp

@@ -34,7 +34,7 @@ class Bullet: public sf::Drawable, public sf::Transformable, public Collidable
 		Bullet() = delete;
 		Bullet() = delete;
 		Bullet(float rotation, sf::Vector2f initialPosition, sf::SoundBuffer& buffer1, sf::SoundBuffer& buffer2, Foreground* foreground);
 		Bullet(float rotation, sf::Vector2f initialPosition, sf::SoundBuffer& buffer1, sf::SoundBuffer& buffer2, Foreground* foreground);
 		void setTexture(sf::Texture& texture);
 		void setTexture(sf::Texture& texture);
-		void update(sf::Time delta);
+		void update(sf::Time delta, sf::Vector2f position);
 		const bool isDead() const;
 		const bool isDead() const;
 	private:
 	private:
 		sf::Vertex _vertex[4];
 		sf::Vertex _vertex[4];

+ 39 - 9
Foreground.cpp

@@ -25,6 +25,8 @@ Foreground::~Foreground()
 		_sprites[i].clear();
 		_sprites[i].clear();
 	_sprites.clear();
 	_sprites.clear();
 	_tiles.clear();
 	_tiles.clear();
+	_normalSprites.clear();
+	_normalTiles.clear();
 }
 }
 
 
 const sf::Vector2u Foreground::getSize() const
 const sf::Vector2u Foreground::getSize() const
@@ -54,6 +56,7 @@ void Foreground::reloadFromTile(int x, int y, bool neighbouring)
 					continue;
 					continue;
 				unsigned id = (y + j) * _tileCount.x + (x + i);
 				unsigned id = (y + j) * _tileCount.x + (x + i);
 				_tiles[id].second.loadFromImage(_tiles[id].first);
 				_tiles[id].second.loadFromImage(_tiles[id].first);
+				_normalTiles[id].second.loadFromImage(_normalTiles[id].first);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -61,6 +64,7 @@ void Foreground::reloadFromTile(int x, int y, bool neighbouring)
 	{
 	{
 		unsigned id = y * _tileCount.x + x;
 		unsigned id = y * _tileCount.x + x;
 		_tiles[id].second.loadFromImage(_tiles[id].first);
 		_tiles[id].second.loadFromImage(_tiles[id].first);
+		_normalTiles[id].second.loadFromImage(_normalTiles[id].first);
 	}
 	}
 }
 }
 
 
@@ -81,6 +85,7 @@ bool Foreground::destroy(unsigned x, unsigned y)
 	if(a > 0)
 	if(a > 0)
 	{
 	{
 		_tiles[id].first.setPixel(x, y, sf::Color::Transparent);
 		_tiles[id].first.setPixel(x, y, sf::Color::Transparent);
+		_normalTiles[id].first.setPixel(x, y, sf::Color::Transparent);
 		return true;
 		return true;
 	}
 	}
 	else
 	else
@@ -92,7 +97,7 @@ const unsigned Foreground::getTileSize() const
 	return _tileSize;
 	return _tileSize;
 }
 }
 
 
-void Foreground::create(sf::Image& foreground, sf::Image& map)
+void Foreground::create(sf::Image& foreground, sf::Image& normal, sf::Image& map)
 {
 {
 	_tileSize = 512;
 	_tileSize = 512;
 	_position.x = 0; _position.y = 0;
 	_position.x = 0; _position.y = 0;
@@ -101,34 +106,49 @@ void Foreground::create(sf::Image& foreground, sf::Image& map)
 	_tiles.clear();
 	_tiles.clear();
 	_tiles.resize(_tileCount.x * _tileCount.y);
 	_tiles.resize(_tileCount.x * _tileCount.y);
 	_sprites.resize(_tileCount.x);
 	_sprites.resize(_tileCount.x);
+	_normalTiles.clear();
+	_normalTiles.resize(_tileCount.x * _tileCount.y);
+	_normalSprites.resize(_tileCount.x);
 	for(unsigned i = 0; i < _tileCount.x; ++i)
 	for(unsigned i = 0; i < _tileCount.x; ++i)
+	{
 		_sprites[i].resize(_tileCount.y);
 		_sprites[i].resize(_tileCount.y);
+		_normalSprites[i].resize(_tileCount.y);
+	}
 	for(unsigned i = 0; i < _tiles.size(); ++i)
 	for(unsigned i = 0; i < _tiles.size(); ++i)
+	{
+		// std::get instead of .first and .second because it used to be a tuple
+		// and I did not rewrite this.
 		std::get<0>(_tiles[i]).create(_tileSize, _tileSize, sf::Color::Yellow);
 		std::get<0>(_tiles[i]).create(_tileSize, _tileSize, sf::Color::Yellow);
+		std::get<0>(_normalTiles[i]).create(_tileSize, _tileSize, sf::Color::Yellow);
+	}
 	for(unsigned i = 0; i < _tileCount.x * _tileSize; ++i)
 	for(unsigned i = 0; i < _tileCount.x * _tileSize; ++i)
 		for(unsigned j = 0; j < _tileCount.y * _tileSize; ++j)
 		for(unsigned j = 0; j < _tileCount.y * _tileSize; ++j)
 		{
 		{
 			sf::Color color = foreground.getPixel(i % foreground.getSize().x, j % foreground.getSize().y);
 			sf::Color color = foreground.getPixel(i % foreground.getSize().x, j % foreground.getSize().y);
 			std::get<0>(_tiles[j / _tileSize * _tileCount.x + i / _tileSize])
 			std::get<0>(_tiles[j / _tileSize * _tileCount.x + i / _tileSize])
 			.setPixel(i % _tileSize, j % _tileSize, sf::Color(color.r, color.g, color.b, i < map.getSize().x and j < map.getSize().y ? 255 - map.getPixel(i, j).r : 255));
 			.setPixel(i % _tileSize, j % _tileSize, sf::Color(color.r, color.g, color.b, i < map.getSize().x and j < map.getSize().y ? 255 - map.getPixel(i, j).r : 255));
+			color = normal.getPixel(i % normal.getSize().x, j % normal.getSize().y);
+			std::get<0>(_normalTiles[j / _tileSize * _tileCount.x + i / _tileSize])
+			.setPixel(i % _tileSize, j % _tileSize, sf::Color(color.r, color.g, color.b, i < map.getSize().x and j < map.getSize().y ? 255 - map.getPixel(i, j).r : 255));
 		}
 		}
 	for(unsigned i = 0; i < _tiles.size(); ++i)
 	for(unsigned i = 0; i < _tiles.size(); ++i)
 	{
 	{
 		std::get<1>(_tiles[i]).loadFromImage(std::get<0>(_tiles[i]));
 		std::get<1>(_tiles[i]).loadFromImage(std::get<0>(_tiles[i]));
 		_sprites[i % _tileCount.x][i / _tileCount.x].setTexture(std::get<1>(_tiles[i]));
 		_sprites[i % _tileCount.x][i / _tileCount.x].setTexture(std::get<1>(_tiles[i]));
 		_sprites[i % _tileCount.x][i / _tileCount.x].setPosition((i % _tileCount.x) * _tileSize, (i / _tileCount.x) * _tileSize);
 		_sprites[i % _tileCount.x][i / _tileCount.x].setPosition((i % _tileCount.x) * _tileSize, (i / _tileCount.x) * _tileSize);
-		//_sprites[i % _tileCount.x][i / _tileCount.x].setColor(sf::Color(rand() % 256,rand() % 256,rand() % 256, 255)); //Debug
-		//std::get<2>(_tiles[i]).setTexture(std::get<1>(_tiles[i]));
-		//std::get<2>(_tiles[i]).setPosition((i % _tileCount.x) * _tileSize, (i / _tileCount.x) * _tileSize);
+		std::get<1>(_normalTiles[i]).loadFromImage(std::get<0>(_normalTiles[i]));
+		_normalSprites[i % _tileCount.x][i / _tileCount.x].setTexture(std::get<1>(_normalTiles[i]));
+		_normalSprites[i % _tileCount.x][i / _tileCount.x].setPosition((i % _tileCount.x) * _tileSize, (i / _tileCount.x) * _tileSize);
 	}
 	}
 }
 }
 
 
-void Foreground::create(std::string foreground, std::string map)
+void Foreground::create(std::string foreground, std::string normal, std::string map)
 {
 {
-	sf::Image image1, image2;
+	sf::Image image1, image2, image3;
 	image1.loadFromFile(foreground);
 	image1.loadFromFile(foreground);
-	image2.loadFromFile(map);
-	create(image1, image2);
+	image2.loadFromFile(normal);
+	image3.loadFromFile(map);
+	create(image1, image2, image3);
 }
 }
 
 
 void Foreground::setResolution(sf::Vector2u resolution)
 void Foreground::setResolution(sf::Vector2u resolution)
@@ -145,11 +165,21 @@ void Foreground::setPosition(sf::Vector2f position)
 	_position.y = position.y >= 0 ? position.y : 0;
 	_position.y = position.y >= 0 ? position.y : 0;
 }
 }
 
 
+void Foreground::renderNormals(bool render)
+{
+	_renderNormals = render;
+}
+
 void Foreground::draw(sf::RenderTarget& target, sf::RenderStates states) const
 void Foreground::draw(sf::RenderTarget& target, sf::RenderStates states) const
 {
 {
 	unsigned x = _position.x / _tileSize, y = _position.y / _tileSize;
 	unsigned x = _position.x / _tileSize, y = _position.y / _tileSize;
 	for(unsigned i = 0; i < _renderCount.x; ++i)
 	for(unsigned i = 0; i < _renderCount.x; ++i)
 			for(unsigned j = 0; j < _renderCount.y; ++j)
 			for(unsigned j = 0; j < _renderCount.y; ++j)
 				if(i + x < _tileCount.x and j + y < _tileCount.y)
 				if(i + x < _tileCount.x and j + y < _tileCount.y)
-					target.draw(_sprites[i + x][j + y], states);
+				{
+					if(!_renderNormals)
+						target.draw(_sprites[i + x][j + y], states);
+					else
+						target.draw(_normalSprites[i + x][j + y], states);
+				}
 }
 }

+ 6 - 2
Foreground.hpp

@@ -32,8 +32,8 @@ class Foreground: public sf::Drawable
 	public:
 	public:
 		Foreground() = default;
 		Foreground() = default;
 		~Foreground();
 		~Foreground();
-		void create(sf::Image& foreground, sf::Image& map);
-		void create(std::string foreground, std::string map);
+		void create(sf::Image& foreground, sf::Image& normal, sf::Image& map);
+		void create(std::string foreground, std::string normal, std::string map);
 		void setResolution(sf::Vector2u resolution);
 		void setResolution(sf::Vector2u resolution);
 		void setPosition(sf::Vector2f position);
 		void setPosition(sf::Vector2f position);
 		void reloadFromTile(int x, int y, bool neighbouring = false);
 		void reloadFromTile(int x, int y, bool neighbouring = false);
@@ -42,14 +42,18 @@ class Foreground: public sf::Drawable
 		const sf::Vector2u getSize() const;
 		const sf::Vector2u getSize() const;
 		const unsigned getTileSize() const;
 		const unsigned getTileSize() const;
 		unsigned const tileAlpha(unsigned x, unsigned y, unsigned pixelX, unsigned pixelY);
 		unsigned const tileAlpha(unsigned x, unsigned y, unsigned pixelX, unsigned pixelY);
+		void renderNormals(bool render);
 
 
 	private:
 	private:
 		void draw(sf::RenderTarget& target, sf::RenderStates states) const;
 		void draw(sf::RenderTarget& target, sf::RenderStates states) const;
 		std::vector<std::pair<sf::Image, sf::Texture>> _tiles;
 		std::vector<std::pair<sf::Image, sf::Texture>> _tiles;
 		std::vector<std::vector<sf::Sprite>> _sprites;
 		std::vector<std::vector<sf::Sprite>> _sprites;
+		std::vector<std::pair<sf::Image, sf::Texture>> _normalTiles;
+		std::vector<std::vector<sf::Sprite>> _normalSprites;
 		sf::Vector2u _renderCount;
 		sf::Vector2u _renderCount;
 		sf::Vector2u _tileCount;
 		sf::Vector2u _tileCount;
 		unsigned _tileSize;
 		unsigned _tileSize;
 		sf::Vector2u _position;
 		sf::Vector2u _position;
+		bool _renderNormals;
 };
 };
 
 

+ 17 - 0
GuiTriangle.hpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #pragma once
 #pragma once
 
 
 #include "Triangle.hpp"
 #include "Triangle.hpp"

+ 70 - 48
IngameState.cpp

@@ -1,12 +1,25 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "IngameState.hpp"
 #include "IngameState.hpp"
 #include "Player.hpp"
 #include "Player.hpp"
 #include <thread>
 #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) {}
 
 
 Rect Player::getBounds()
 Rect Player::getBounds()
 {
 {
@@ -25,31 +38,33 @@ Rect Player::getBounds()
 
 
 void IngameState::init()
 void IngameState::init()
 {
 {
-	_background.setTexture(_context->assets->loadTexture("data/background/Background.png"));
-	_context->assets->loadTexture("data/background/Background.png").setRepeated(true);
+	_background.setTexture(_context->assets->loadTexture("data/background/Background.jpg"));
+	_context->assets->loadTexture("data/background/Background.jpg").setRepeated(true);
 
 
 	_player.setContext(_context);
 	_player.setContext(_context);
-	_player.setTexture(_context->assets->loadTexture("data/triangle/Texture.png"));
+	_player.setTexture(_context->assets->loadTexture(rand() % 10 == 0 ? "data/triangle/Illuminati.png" : "data/triangle/Texture.png"));
 	_player.setPosition(400.f, 400.f);
 	_player.setPosition(400.f, 400.f);
 	
 	
-	_foreground.create("data/background/Foreground.png", "data/background/75pxjitter03.png");
+	_foreground.create("data/background/Foreground.jpg", "data/background/Foreground_normal.jpg", "data/background/75pxjitter03.png");
 	_context->foreground = &_foreground;
 	_context->foreground = &_foreground;
 	
 	
+	_background.setTextureRect(sf::IntRect(0, 0, _foreground.getSize().x, _foreground.getSize().y));
+	
 	_pauseFrame.setFillColor(sf::Color(0, 0, 0, 155));
 	_pauseFrame.setFillColor(sf::Color(0, 0, 0, 155));
 	_pauseFrame.setPosition(0, 0);
 	_pauseFrame.setPosition(0, 0);
 	
 	
-	/*_unshadowShader.loadFromFile("assets/unshadowShader.frag", sf::Shader::Fragment);
-    _lightOverShapeShader.loadFromFile("assets/lightOverShapeShader.frag", sf::Shader::Fragment);
-    _normalsShader.loadFromFile("assets/normalsShader.frag", sf::Shader::Fragment);
+	_unshadowShader.loadFromFile("data/light/unshadowShader.frag", sf::Shader::Fragment);
+    _lightOverShapeShader.loadFromFile("data/light/lightOverShapeShader.frag", sf::Shader::Fragment);
+    _normalsShader.loadFromFile("data/light/normalsShader.frag", sf::Shader::Fragment);
 	_penumbraTexture.loadFromFile("data/light/penumbraTexture.png");
 	_penumbraTexture.loadFromFile("data/light/penumbraTexture.png");
-	_penumbraTexture.setSmooth(true);*/
+	_penumbraTexture.setSmooth(true);
 	
 	
-	/*_light = std::make_shared<ltbl::LightPointEmission>();
-	_light->_emissionSprite.setOrigin(330.f, 871.f);
+	_light = std::make_shared<ltbl::LightPointEmission>();
 	_light->_emissionSprite.setPosition(0.f, 0.f);
 	_light->_emissionSprite.setPosition(0.f, 0.f);
-	_light->_emissionSprite.setTexture(_context->assets->loadTexture("data/background/texture.png"));
+	_light->_emissionSprite.setTexture(_context->assets->loadTexture("data/background/Light.png"));
+	_light->_emissionSprite.setOrigin(sf::Vector2f(_context->assets->loadTexture("data/background/Light.png").getSize() / 2u));
 	_light->_emissionSprite.setColor(sf::Color::White);
 	_light->_emissionSprite.setColor(sf::Color::White);
-	_light->_localCastCenter = sf::Vector2f(0.0f, 0.0f); // This is where the shadows emanate from relative to the sprite*/
+	_light->_localCastCenter = sf::Vector2f(0.0f, 0.0f); // This is where the shadows emanate from relative to the sprite
 	
 	
 	_blurV.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-v.frag");
 	_blurV.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-v.frag");
 	_blurH.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-h.frag");
 	_blurH.loadFromFile("data/shaders/old_pi_blur/blur.vert", "data/shaders/old_pi_blur/blur-h.frag");
@@ -65,7 +80,7 @@ void IngameState::init()
 void IngameState::refresh()
 void IngameState::refresh()
 {
 {
 	sf::Vector2u res = _context->window->getSize();
 	sf::Vector2u res = _context->window->getSize();
-	_background.setTextureRect(sf::IntRect(0, 0, _context->window->getSize().x, _context->window->getSize().y));
+	//_background.setTextureRect(sf::IntRect(0, 0, _context->window->getSize().x, _context->window->getSize().y));
 	_camera.setSize(static_cast<sf::Vector2f>(_context->window->getSize()));
 	_camera.setSize(static_cast<sf::Vector2f>(_context->window->getSize()));
 	_camera.setTwilightViewport(_context->window->getSize().x / 2.f - 240.f/* * (bool) _czyWOgóleTwilightViewportMaByć*/, _context->window->getSize().y / 2.f - 240.f);
 	_camera.setTwilightViewport(_context->window->getSize().x / 2.f - 240.f/* * (bool) _czyWOgóleTwilightViewportMaByć*/, _context->window->getSize().y / 2.f - 240.f);
 	_camera.setCenter(_player.getPosition());
 	_camera.setCenter(_player.getPosition());
@@ -78,10 +93,10 @@ void IngameState::refresh()
 	
 	
 	_backgroundH.create(_context->window->getSize().x, _context->window->getSize().y);
 	_backgroundH.create(_context->window->getSize().x, _context->window->getSize().y);
 	_backgroundV.create(_context->window->getSize().x, _context->window->getSize().y);
 	_backgroundV.create(_context->window->getSize().x, _context->window->getSize().y);
-	
-	//_lightSystem.create(sf::FloatRect{{0.f, 0.f}, {0.f, 0.f}}, {1920, 1080}, _penumbraTexture, _unshadowShader, _lightOverShapeShader, _normalsShader);
-	//_lightSystem.normalsEnabled(true);
-	//_lightSystem.addLight(_light);
+
+	_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);
 }
 }
 
 
 void IngameState::coreThink(const sf::Event& event)
 void IngameState::coreThink(const sf::Event& event)
@@ -133,8 +148,7 @@ void IngameState::coreUpdate(sf::Time delta)
 	const sf::Vector2f pos = _player.getPosition();
 	const sf::Vector2f pos = _player.getPosition();
 	_player.update(delta);
 	_player.update(delta);
 	_camera.move(_player.getPosition() - pos);
 	_camera.move(_player.getPosition() - pos);
-	//_light->_emissionSprite.setPosition(_player.getPosition());
-	//_light->_emissionSprite.setRotation(_player.getRotation());
+	_light->_emissionSprite.setPosition(_player.getPosition());
 	_foreground.setPosition(_camera.getCenter() - _camera.getSize() / 2.f);
 	_foreground.setPosition(_camera.getCenter() - _camera.getSize() / 2.f);
 	
 	
 	if(_player.checkCollision(_foreground)) /// True if the target died.
 	if(_player.checkCollision(_foreground)) /// True if the target died.
@@ -147,19 +161,22 @@ void IngameState::coreRender(const bool shaders)
 {
 {
 	if(_player.isDead())
 	if(_player.isDead())
 	{
 	{
-	//	_blurH.setParameter("RTScene", backgroundH.getTexture());
-	//	_blurV.setParameter("RTBlurH", backgroundV.getTexture());
-		
-		_background.setTexture(_context->assets->loadTexture("data/background/Background.png"));
 		_backgroundH.draw(_background);
 		_backgroundH.draw(_background);
 		_backgroundH.setView(*_camera.getView());
 		_backgroundH.setView(*_camera.getView());
 		_backgroundH.draw(_foreground);
 		_backgroundH.draw(_foreground);
 		_backgroundH.draw(_player);
 		_backgroundH.draw(_player);
+		sf::Sprite sprite3(_lightSystem.getLightingTexture());
+		sf::RenderStates lightRenderStates;
+		lightRenderStates.blendMode = sf::BlendMultiply;
+		_backgroundH.setView(_context->window->getDefaultView());
+		_backgroundH.draw(sprite3, lightRenderStates); 
+
 		sf::Sprite sprite(_backgroundH.getTexture());
 		sf::Sprite sprite(_backgroundH.getTexture());
 		sprite.setScale(1.f, -1.f);
 		sprite.setScale(1.f, -1.f);
 		sprite.setOrigin(0, _context->window->getSize().y);
 		sprite.setOrigin(0, _context->window->getSize().y);
 		sprite.setPosition(0.f, 0.f);
 		sprite.setPosition(0.f, 0.f);
 		_backgroundV.draw(sprite, &_blurH);
 		_backgroundV.draw(sprite, &_blurH);
+
 		sf::Sprite sprite2(_backgroundV.getTexture());
 		sf::Sprite sprite2(_backgroundV.getTexture());
 		sprite2.setScale(1.f, -1.f);
 		sprite2.setScale(1.f, -1.f);
 		sprite2.setOrigin(0, _context->window->getSize().y);
 		sprite2.setOrigin(0, _context->window->getSize().y);
@@ -170,25 +187,30 @@ void IngameState::coreRender(const bool shaders)
 	}
 	}
 	else
 	else
 	{
 	{
-	
-	//_lightSystem.normalsTargetClear();
-	_background.setTexture(_context->assets->loadTexture("data/background/Background.png"));
-	_context->window->draw(_background);//, &_normalBackground);
-	//_background.setTexture(_context->assets->loadTexture("data/background/normal.JPG"));
-	//_lightSystem.normalsTargetDraw(_background);
-	//_lightSystem.normalsTargetDraw(_foreground);
-	_context->window->setView(_camera.getView());
-	_context->window->draw(_foreground);
-	//_context->window->draw(_foreground);
-	_context->window->draw(_player);
-	//_lightSystem.normalsTargetDisplay();
-	//_lightSystem.render(*_camera.getView(), _unshadowShader, _lightOverShapeShader, _normalsShader);
-	//sf::Sprite sprite(_lightSystem.getLightingTexture());
-	//sf::RenderStates lightRenderStates;
-    //lightRenderStates.blendMode = sf::BlendMultiply;
-	//_context->window->draw(sprite, lightRenderStates);
-	_context->window->setView();
-	if(_paused)
-		_context->window->draw(_pauseFrame);
+		_context->window->setView(_camera.getView());
+		_context->window->draw(_background);
+		
+		
+		_foreground.renderNormals(true);
+		_lightSystem.normalsTargetSetView(*_camera.getView());
+		_lightSystem.normalsTargetClear();
+		_lightSystem.normalsTargetDraw(_foreground);
+		_lightSystem.normalsTargetDisplay();
+		_lightSystem.render(*_camera.getView(), _unshadowShader, _lightOverShapeShader, _normalsShader);
+		
+		
+		_foreground.renderNormals(false);
+		_context->window->draw(_foreground);
+		_context->window->draw(_player);
+		
+		
+		_context->window->setView();
+		sf::Sprite sprite(_lightSystem.getLightingTexture());
+		sf::RenderStates lightRenderStates;
+		lightRenderStates.blendMode = sf::BlendMultiply;
+		_context->window->draw(sprite, lightRenderStates); 
+		
+		if(_paused)
+			_context->window->draw(_pauseFrame);
 	}
 	}
 }
 }

+ 19 - 2
IngameState.hpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #pragma once
 #pragma once
 
 
 #include "State.hpp"
 #include "State.hpp"
@@ -26,12 +43,12 @@ class IngameState: public State
 		Camera _camera;
 		Camera _camera;
 		sf::Sprite _background;
 		sf::Sprite _background;
 		
 		
-		/*sf::Shader _unshadowShader;
+		sf::Shader _unshadowShader;
 		sf::Shader _lightOverShapeShader;
 		sf::Shader _lightOverShapeShader;
 		sf::Shader _normalsShader;
 		sf::Shader _normalsShader;
 		sf::Texture _penumbraTexture;
 		sf::Texture _penumbraTexture;
 		ltbl::LightSystem _lightSystem;
 		ltbl::LightSystem _lightSystem;
-		std::shared_ptr<ltbl::LightPointEmission> _light;*/
+		std::shared_ptr<ltbl::LightPointEmission> _light;
 		
 		
 		bool _cameraMode;
 		bool _cameraMode;
 		bool _paused;
 		bool _paused;

+ 17 - 0
Input.cpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "Input.hpp"
 #include "Input.hpp"
 
 
 Input::Input(const Input& other): _type(other._type), _positive(other._positive)
 Input::Input(const Input& other): _type(other._type), _positive(other._positive)

+ 17 - 0
Input.hpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #pragma once
 #pragma once
 
 
 #include <SFML/Window.hpp>
 #include <SFML/Window.hpp>

+ 17 - 0
InputMap.hpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #pragma once
 #pragma once
 
 
 #include <unordered_map>
 #include <unordered_map>

+ 17 - 0
InputTarget.hpp

@@ -1,3 +1,20 @@
+/**
+ *  Triangles
+ *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, version 3 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #pragma once
 #pragma once
 
 
 #include <list>
 #include <list>

+ 41 - 29
Particle.cpp

@@ -21,55 +21,60 @@
   */
   */
 
 
 #include <sstream>
 #include <sstream>
+#include <cmath>
 #include "Particle.hpp"
 #include "Particle.hpp"
 
 
-ParticleSystem::ParticleSystem( int width, int height )
+ParticleSystem::ParticleSystem(int width, int height):
+	_origin(0, 0),
+	_particleSpeed(20.f),
+	_dissolutionRate(60.f),
+	_enabled(true) 
 {
 {
-	_transparent = sf::Color( 0, 0, 0, 0 );
-	_image.create( width, height, _transparent );
+	_colors.push_back(sf::Color::White);
+	_image.create( width, height, sf::Color::Transparent);
 	_texture.loadFromImage(_image);
 	_texture.loadFromImage(_image);
 	_sprite = sf::Sprite(_texture);
 	_sprite = sf::Sprite(_texture);
-	_position.x	= 0.5f * width;
-	_position.y	= 0.5f * height;
-	_particleSpeed = 20.0f;
-	_dissolutionRate = 60.f;
 }
 }
 
 
 ParticleSystem::~ParticleSystem()
 ParticleSystem::~ParticleSystem()
 {
 {
 	for(auto it = _particles.begin(); it != _particles.end(); it++)
 	for(auto it = _particles.begin(); it != _particles.end(); it++)
-	{
 		delete *it;
 		delete *it;
-	}
 }
 }
 
 
 void ParticleSystem::fuel(int particles, float angle)
 void ParticleSystem::fuel(int particles, float angle)
 {
 {
+	if(!_enabled)
+		return;
+		
+	if(particles < 0)
+		particles = -particles;
+		
+	if(_particles.size() > 40000)
+		return;
+
 	Particle* particle;
 	Particle* particle;
-	const double degree = 3.14159265358 / 180.;
 	for(int i = 0; i < particles; i++)
 	for(int i = 0; i < particles; i++)
 	{
 	{
 		particle = new Particle();
 		particle = new Particle();
-		particle->pos.x = _position.x;
-		particle->pos.y = _position.y;
-	
-		do
-		{
-			particle->vel.x = _randomizer.rnd(0.0f, 15.0f) * -std::sin(angle * degree);
-			particle->vel.y = _randomizer.rnd(0.0f, 15.0f) * std::cos(angle * degree);
-		} while(particle->vel.x == 0.0f && particle->vel.y == 0.0f);
+		particle->pos.x = _origin.x;
+		particle->pos.y = _origin.y;
+		
+		particle->vel.x = float((rand() % 30000 - 15000) / 1000.f);
+		particle->vel.y = float((rand() % 30000 - 15000) / 1000.f);
 
 
-		particle->color.r = std::rand() % 100 + 150;
-		particle->color.g = std::rand() % 50 + 150;
-        particle->color.b = std::rand() % 50;
+		particle->color = _colors[rand() % _colors.size()];
 		particle->transparency = 255.f;
 		particle->transparency = 255.f;
 		particle->color.a = sf::Uint8(particle->transparency);
 		particle->color.a = sf::Uint8(particle->transparency);
 		_particles.push_back(particle);
 		_particles.push_back(particle);
 	}
 	}
 }
 }
-#include "iostream"
+
 void ParticleSystem::update(sf::Time delta)
 void ParticleSystem::update(sf::Time delta)
 {
 {
+	if(!_enabled)
+		return;
+
 	float time = delta.asSeconds();
 	float time = delta.asSeconds();
 
 
 	for(auto it = _particles.begin(); it != _particles.end(); it++ )
 	for(auto it = _particles.begin(); it != _particles.end(); it++ )
@@ -92,17 +97,24 @@ void ParticleSystem::update(sf::Time delta)
 
 
 void ParticleSystem::render()
 void ParticleSystem::render()
 {
 {
-	for(auto it = _particles.begin(); it != _particles.end(); it++ )
-	{
-  	  _image.setPixel( (int)(*it)->pos.x, (int)(*it)->pos.y, (*it)->color );
-	}
+	if(!_enabled)
+		return;
+
+	for(auto it = _particles.begin(); it != _particles.end(); it++)
+		_image.setPixel((int)(*it)->pos.x, (int)(*it)->pos.y, (*it)->color);
     _texture.update(_image);
     _texture.update(_image);
 }
 }
 
 
 void ParticleSystem::clear()
 void ParticleSystem::clear()
 {
 {
+	if(!_enabled)
+		return;
+		
 	for(auto it = _particles.begin(); it != _particles.end(); it++ )
 	for(auto it = _particles.begin(); it != _particles.end(); it++ )
-	{
-	    _image.setPixel( (int)(*it)->pos.x, (int)(*it)->pos.y, _transparent );
-	}
+		_image.setPixel( (int)(*it)->pos.x, (int)(*it)->pos.y, sf::Color::Transparent);
+}
+
+void ParticleSystem::draw(sf::RenderTarget& target, sf::RenderStates states) const
+{
+	target.draw(_sprite);
 }
 }

+ 50 - 45
Particle.hpp

@@ -22,59 +22,56 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <SFML/System/Vector2.hpp>
-#include <SFML/System/Clock.hpp>
-#include <SFML/Graphics/Color.hpp>
-#include <SFML/Graphics/Image.hpp>
-#include <SFML/Graphics/Sprite.hpp>
-#include <SFML/Graphics/Texture.hpp>
 #include <vector>
 #include <vector>
-#include <random>
+#include <SFML/Graphics.hpp>
+#include <iostream>
 
 
-class Randomizer 
-{
-    public:
-        Randomizer() : device_(), engine_(device_()){};
-        int rnd(int a, int b) {
-            std::uniform_int_distribution<int> uni_dist(a, b);
-            return uni_dist(engine_);
-        };
-        double rnd(double a, double b) {
-            std::uniform_real_distribution<double> uni_dist(a, b);
-            return uni_dist(engine_);
-        };
-    private:
-        std::random_device device_;
-        std::default_random_engine engine_;
-};
-
-struct Particle
-{
-    sf::Vector2f pos;
-    sf::Vector2f vel;
-    sf::Color color;
-	float transparency;
-};
-
-class ParticleSystem
+class ParticleSystem: public sf::Drawable
 {
 {
 	public:
 	public:
-		ParticleSystem( int width, int height );
+		ParticleSystem(int width, int height);
 		~ParticleSystem();
 		~ParticleSystem();
 
 
 		void fuel(int particles, float angle);
 		void fuel(int particles, float angle);
 		void update(sf::Time delta);
 		void update(sf::Time delta);
 		void render();
 		void render();
 		void clear();
 		void clear();
-
+		
+		void enable(bool enabled)
+		{
+			_enabled = enabled;
+		}
+		const bool isEnabled() const
+		{
+			return _enabled;
+		}
+		void loadColors(const sf::Image& image)
+		{
+			_colors.clear();
+			for(unsigned i = 0; i < image.getSize().x; ++i)
+				for(unsigned j = 0; j < image.getSize().y; ++j)
+				{
+					sf::Color color = image.getPixel(i, j);
+					if(color.r > 0 || color.g > 0 || color.b > 0)
+						_colors.emplace_back(color.r, color.g, color.b, 255);
+				}
+		}
 		void setPosition(const sf::Vector2f position) 
 		void setPosition(const sf::Vector2f position) 
 		{ 
 		{ 
-			_position = position;
+			_sprite.setPosition(position - _origin);
 		}
 		}
 		void setPosition(float x, float y) 
 		void setPosition(float x, float y) 
 		{ 
 		{ 
 			setPosition(sf::Vector2f(x, y));
 			setPosition(sf::Vector2f(x, y));
 		}
 		}
+		void setOrigin(const sf::Vector2f origin) 
+		{ 
+			_origin = origin;
+		}
+		void setOrigin(float x, float y) 
+		{ 
+			setOrigin(sf::Vector2f(x, y));
+		}
 		void setParticleSpeed(float particleSpeed) 
 		void setParticleSpeed(float particleSpeed) 
 		{ 
 		{ 
 			_particleSpeed = particleSpeed; 
 			_particleSpeed = particleSpeed; 
@@ -87,16 +84,24 @@ class ParticleSystem
 		{ 
 		{ 
 			return _sprite; 
 			return _sprite; 
 		}
 		}
-
+ 
 	private:
 	private:
-		sf::Vector2f			_position; // Particle origin (pixel co-ordinates)
-		sf::Clock   			_clock;    // Used to scale particle motion
-		sf::Color   			_transparent;  // sf::Color( 0, 0, 0, 0 )
-		sf::Image   			_image;    // See render() and remove()
-		sf::Texture 			_texture;
-		Randomizer  			_randomizer;
-		sf::Sprite  			_sprite;   // Connected to m_image
-		float       			_particleSpeed;// Pixels per second (at most)
+		struct Particle
+		{
+			sf::Vector2f pos;
+			sf::Vector2f vel;
+			sf::Color color;
+			float transparency;
+		};
+		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
+		sf::Vector2f			_origin;
+		sf::Clock				_clock;
+		sf::Image				_image;
+		sf::Texture				_texture;
+		sf::Sprite				_sprite;
+		float					_particleSpeed;
 		float	 				_dissolutionRate;
 		float	 				_dissolutionRate;
 		std::vector<Particle*>	_particles;
 		std::vector<Particle*>	_particles;
+		std::vector<sf::Color>	_colors;
+		bool _enabled;
 };
 };

+ 26 - 10
Player.cpp

@@ -35,7 +35,7 @@ Player::Player():
 	_rotationSuppresion(20.f),
 	_rotationSuppresion(20.f),
 	_hit(false),
 	_hit(false),
 	_dead(false),
 	_dead(false),
-	_particleSystem(1920, 1080)
+	_particleSystem(512, 512)
 {
 {
 	/**
 	/**
 	 *  Default binding
 	 *  Default binding
@@ -56,6 +56,7 @@ Player::Player():
 		_inputMap.map(4, Input(sf::Keyboard::D));
 		_inputMap.map(4, Input(sf::Keyboard::D));
 		_inputMap.map(5, Input(sf::Keyboard::Space));
 		_inputMap.map(5, Input(sf::Keyboard::Space));
 	 }
 	 }
+	_inputMap.map(40, Input(sf::Keyboard::F9, Input::Type::Pressed));
 	
 	
 	/**
 	/**
 	 *  Input lambdas
 	 *  Input lambdas
@@ -78,7 +79,7 @@ Player::Player():
 	});
 	});
 	bind(5, [this](const sf::Event&, float)
 	bind(5, [this](const sf::Event&, float)
 	{
 	{
-		if(_bulletTimer.getElapsedTime().asMilliseconds() > 1500)
+		if(_bulletTimer.getElapsedTime().asMilliseconds() > 750)
 		{
 		{
 			// Does not check if _context != nullptr
 			// Does not check if _context != nullptr
 			// so please do remember to call setContext().
 			// so please do remember to call setContext().
@@ -88,10 +89,15 @@ Player::Player():
 								_context->foreground);
 								_context->foreground);
 			_bullets.back().setTexture(_innerTexture);
 			_bullets.back().setTexture(_innerTexture);
 			_bulletTimer.restart();
 			_bulletTimer.restart();
-			_movementMomentum -= 3.f;
+			_movementMomentum -= (rand() % 2000 + 6000) / 1000.f;
 		}
 		}
 	});
 	});
 	
 	
+	bind(40, [this](const sf::Event&, float)
+	{
+		_particleSystem.enable(!_particleSystem.isEnabled());
+	});
+	
 	/**
 	/**
 	*  Particles
 	*  Particles
 	*/
 	*/
@@ -104,6 +110,8 @@ Player::Player():
 	
 	
 	genCollisionBox("data/hitbox/Player.png", sf::Vector2f(71.f, 100.f));
 	genCollisionBox("data/hitbox/Player.png", sf::Vector2f(71.f, 100.f));
 	
 	
+	_particleSystem.setOrigin(256.f, 256.f);
+	
 	_bullets.reserve(10);
 	_bullets.reserve(10);
 	_bulletTimer.restart();
 	_bulletTimer.restart();
 	 
 	 
@@ -126,6 +134,7 @@ void Player::setTexture(sf::Texture& texture)
 {
 {
 	_innerTexture = texture;
 	_innerTexture = texture;
 	_image = texture.copyToImage();
 	_image = texture.copyToImage();
+	_particleSystem.loadColors(_image);
 	_texture = &_innerTexture;
 	_texture = &_innerTexture;
 	vertexFit();
 	vertexFit();
 	
 	
@@ -344,23 +353,30 @@ void Player::update(sf::Time delta)
 	//else
 	//else
 		keyboardControls(delta);
 		keyboardControls(delta);
 	
 	
+	bool all = false;
 	for(unsigned i = 0; i < _bullets.size(); ++i)
 	for(unsigned i = 0; i < _bullets.size(); ++i)
 	{
 	{
-		_bullets[i].update(delta);
-		if(_bullets[i].isDead())
-			_bullets.erase(_bullets.begin() + i);
+		_bullets[i].update(delta, getPosition());
+
+		if(!_bullets[i].isDead())
+			all = true;
 	}
 	}
+	if(!all)
+		_bullets.clear();
 
 
 	_particleSystem.setPosition(getPosition());
 	_particleSystem.setPosition(getPosition());
+	
+	sf::Listener::setPosition(getPosition().x, getPosition().y, 0);
 
 
 	_particleSystem.clear();
 	_particleSystem.clear();
-    _particleSystem.update(delta);
-    _particleSystem.render();
+	_particleSystem.update(delta);
+	_particleSystem.render();
 }
 }
 
 
 void Player::draw(sf::RenderTarget& target, sf::RenderStates states) const
 void Player::draw(sf::RenderTarget& target, sf::RenderStates states) const
-{	
-	target.draw(_particleSystem.getSprite());
+{
+	if(_particleSystem.isEnabled())
+		target.draw(_particleSystem);
 	
 	
 	for(unsigned i = 0; i < _bullets.size(); ++i)
 	for(unsigned i = 0; i < _bullets.size(); ++i)
 		target.draw(_bullets[i]);
 		target.draw(_bullets[i]);

+ 6 - 2
TrianglesWindow.cpp

@@ -142,7 +142,12 @@ void TrianglesWindow::lockMouse(sf::Vector2i position)
 	_window.setMouseCursorVisible(false);
 	_window.setMouseCursorVisible(false);
 	sf::Mouse::setPosition(position, _window);
 	sf::Mouse::setPosition(position, _window);
 }
 }
-#include "Utility.hpp"
+
+const sf::View& TrianglesWindow::getDefaultView()
+{
+	return _window.getDefaultView();
+}
+
 void TrianglesWindow::open()
 void TrianglesWindow::open()
 {
 {
 	sf::ContextSettings settings;
 	sf::ContextSettings settings;
@@ -151,7 +156,6 @@ void TrianglesWindow::open()
 	settings.antialiasingLevel = 8;
 	settings.antialiasingLevel = 8;
 	_window.create(sf::VideoMode(_size.x, _size.y), _title, (_context->fullscreen ? sf::Style::Fullscreen : (sf::Style::Titlebar | sf::Style::Close)), settings);
 	_window.create(sf::VideoMode(_size.x, _size.y), _title, (_context->fullscreen ? sf::Style::Fullscreen : (sf::Style::Titlebar | sf::Style::Close)), settings);
 	_window.setKeyRepeatEnabled(false);
 	_window.setKeyRepeatEnabled(false);
-	Echo::debug("Debug window position set to 1200 800");
 	_window.setPosition(sf::Vector2i(1200, 800));
 	_window.setPosition(sf::Vector2i(1200, 800));
 	if(_context->vsync)
 	if(_context->vsync)
 		_window.setVerticalSyncEnabled(true);
 		_window.setVerticalSyncEnabled(true);

+ 1 - 0
TrianglesWindow.hpp

@@ -41,6 +41,7 @@ class TrianglesWindow: public InputTarget<int>
 		sf::Vector2u getSize();
 		sf::Vector2u getSize();
 		void setView(const sf::View* view);
 		void setView(const sf::View* view);
 		void setView();
 		void setView();
+		const sf::View& getDefaultView();
 		void draw(sf::Drawable& drawable);
 		void draw(sf::Drawable& drawable);
 		void draw(sf::Drawable& drawable, sf::RenderStates states);
 		void draw(sf::Drawable& drawable, sf::RenderStates states);
 		void draw(sf::Drawable& drawable, sf::Shader* shader);
 		void draw(sf::Drawable& drawable, sf::Shader* shader);

BIN
data/audio/Shotgun.ogg


BIN
data/background/Background.jpg


BIN
data/background/Background.png


BIN
data/background/Foreground.jpg


BIN
data/background/Foreground.png


BIN
data/background/Foreground_normal.jpg


BIN
data/background/Light.png


+ 34 - 0
data/light/normalsShader.frag

@@ -0,0 +1,34 @@
+#version 120
+
+// Input textures
+uniform sampler2D normalsTexture;
+uniform sampler2D lightTexture;
+uniform vec2 targetSize;
+uniform vec2 lightSize;
+
+// Light properties
+uniform vec3 lightPosition;
+uniform vec3 lightColor;
+
+void main()
+{
+	// Sample our normals map
+	vec2 coord = gl_TexCoord[0].xy;
+	float lightPower = texture2D(lightTexture, coord).r;
+	vec4 normalsColor = texture2D(normalsTexture, gl_FragCoord.xy / targetSize);
+	
+	// Get normal value from sample
+	vec3 normals = normalize(normalsColor.rgb * 2.0 - 1.0);
+	
+	// Compute the light vector
+	vec2 lightVector = lightPosition.xy - gl_FragCoord.xy;
+	vec3 lightDir = vec3(lightVector / lightSize, lightPosition.z);
+	lightDir = normalize(lightDir);
+	
+	// Compute the color intensity based on normals
+	float colorIntensity = max(dot(normals, lightDir), 0.0);
+	vec4 diffuse = vec4(lightColor * colorIntensity, lightPower);
+	
+	gl_FragColor = clamp(diffuse, 0.0, 1.0);
+}
+

BIN
data/triangle/Illuminati-Reference-UNUSED.png


BIN
data/triangle/Illuminati.png