Browse Source

v-0.9.9 update

POSITIVE-MENTAL-ATTITUDE 8 years ago
parent
commit
52b9d86a2d

+ 4 - 0
data/background/about.txt

@@ -2,6 +2,10 @@ Wasted.png:
 GTA V "Wasted" screen by LunicAura106: http://lunicaura106.deviantart.com/ http://fav.me/d7t2en9 
 GTA V "Wasted" screen by LunicAura106: http://lunicaura106.deviantart.com/ http://fav.me/d7t2en9 
 Used without permission, I hope no one will kill me.
 Used without permission, I hope no one will kill me.
 
 
+Background.jpg, Foreground.jpg, Foreground_normal.jpg:
+Textures by rubberduck: http://opengameart.org/content/50-free-textures-4-normalmaps
+Licensed under PD/CC0
+
 The rest is created by POSITIVE MENTAL ATTITUDE (https://github.com/POSITIVE-MENTAL-ATTITUDE)
 The rest is created by POSITIVE MENTAL ATTITUDE (https://github.com/POSITIVE-MENTAL-ATTITUDE)
 and licensed under Creative Commons: Attribution-ShareAlike 4.0 International License
 and licensed under Creative Commons: Attribution-ShareAlike 4.0 International License
 http://creativecommons.org/licenses/by-sa/4.0/
 http://creativecommons.org/licenses/by-sa/4.0/

BIN
data/triangle/Wormhole.png


BIN
data/triangle/Wormhole_light.png


+ 12 - 0
data/triangle/about.txt

@@ -0,0 +1,12 @@
+Wormhole.png:
+Wormhole by Xolarix: http://fav.me/d2lh209
+Licensed under Creative Commons: Attribution-Noncommercial-No Derivative Works 3.0 License
+http://creativecommons.org/licenses/by-nc-nd/3.0/
+I actually made a derivative work and I hope no one will murder me for that. Screw CC-NC and CC-ND licenses.
+
+Illuminati.png and reference:
+Somewhere from the internet.
+
+The rest is created by POSITIVE MENTAL ATTITUDE (https://github.com/POSITIVE-MENTAL-ATTITUDE)
+and licensed under Creative Commons: Attribution-ShareAlike 4.0 International License
+http://creativecommons.org/licenses/by-sa/4.0/

+ 1 - 1
src/Assets.cpp

@@ -19,7 +19,7 @@
 #include "Utility.hpp"
 #include "Utility.hpp"
 
 
 Assets::~Assets()
 Assets::~Assets()
-{
+{ 
 	textures.clear();
 	textures.clear();
 	sounds.clear();
 	sounds.clear();
 	fonts.clear();
 	fonts.clear();

+ 2 - 0
src/Circle.cpp

@@ -15,6 +15,7 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
+#include "Utility.hpp"
 #include "Circle.hpp"
 #include "Circle.hpp"
 
 
 Circle::Circle(sf::Color color, float scale): _size(10) 
 Circle::Circle(sf::Color color, float scale): _size(10) 
@@ -30,6 +31,7 @@ Circle::Circle(sf::Color color, float scale): _size(10)
 
 
 Circle::~Circle()
 Circle::~Circle()
 {
 {
+	Echo::debug("Deleting a circle.");
 	_arc.clear();
 	_arc.clear();
 }
 }
 
 

+ 17 - 0
src/GuiButton.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 <sstream>
 #include <sstream>
 #include "GuiButton.hpp"
 #include "GuiButton.hpp"
 
 

+ 17 - 0
src/GuiButton.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/>.
+ */
+
 #include "GuiTriangle.hpp"
 #include "GuiTriangle.hpp"
 
 
 /**
 /**

+ 15 - 1
src/IngameState.cpp

@@ -19,7 +19,14 @@
 #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), _wormhole() {}
+
+IngameState::~IngameState()
+{
+	Echo::debug("Flushing state");
+	_lightSystem.removeLight(_light);
+	_lightSystem.removeLight(_wormhole.light());
+}
 
 
 Rect Player::getBounds()
 Rect Player::getBounds()
 {
 {
@@ -72,6 +79,9 @@ void IngameState::init()
 	_marioSound.setBuffer(_context->assets->loadSound("data/audio/Mario.ogg"));
 	_marioSound.setBuffer(_context->assets->loadSound("data/audio/Mario.ogg"));
 	_wasted.setTexture(_context->assets->loadTexture("data/background/Wasted.png"));
 	_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.
 	// Global window is not initialized yet in this method. If you need _context->window->getSize(), go to refresh() instead.
 	
 	
 	_status = State::Ongoing;
 	_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.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.normalsEnabled(true);
 	_lightSystem.addLight(_light);
 	_lightSystem.addLight(_light);
+	_lightSystem.addLight(_wormhole.light());
 }
 }
 
 
 void IngameState::coreThink(const sf::Event& event)
 void IngameState::coreThink(const sf::Event& event)
@@ -156,6 +167,8 @@ void IngameState::coreUpdate(sf::Time delta)
 		_paused = true;
 		_paused = true;
 		_marioSound.play();
 		_marioSound.play();
 	}
 	}
+	
+	_wormhole.update(delta);
 }
 }
 void IngameState::coreRender(const bool shaders)
 void IngameState::coreRender(const bool shaders)
 {
 {
@@ -201,6 +214,7 @@ void IngameState::coreRender(const bool shaders)
 		
 		
 		_foreground.renderNormals(false);
 		_foreground.renderNormals(false);
 		_context->window->draw(_foreground);
 		_context->window->draw(_foreground);
+		_context->window->draw(_wormhole);
 		_context->window->draw(_player);
 		_context->window->draw(_player);
 		
 		
 		
 		

+ 5 - 1
src/IngameState.hpp

@@ -21,15 +21,17 @@
 #include "Player.hpp"
 #include "Player.hpp"
 #include "Foreground.hpp"
 #include "Foreground.hpp"
 #include "Camera.hpp"
 #include "Camera.hpp"
+#include "Wormhole.hpp"
 #include "ltbl/lighting/LightSystem.h"
 #include "ltbl/lighting/LightSystem.h"
 
 
 class IngameState: public State
 class IngameState: public State
 {
 {
 	public:
 	public:
 		IngameState();
 		IngameState();
+		virtual ~IngameState();
 		void init() final;
 		void init() final;
 		/**
 		/**
-		* @brief Method casted whenever the game's resolution changes.
+		* @brief Method casted whenever the ga		me's resolution changes.
 		*/
 		*/
 		void refresh() final;
 		void refresh() final;
 		void coreThink(const sf::Event& event) final;
 		void coreThink(const sf::Event& event) final;
@@ -63,5 +65,7 @@ class IngameState: public State
 		sf::Sound _marioSound;
 		sf::Sound _marioSound;
 		sf::RenderTexture _backgroundH;
 		sf::RenderTexture _backgroundH;
 		sf::RenderTexture _backgroundV;
 		sf::RenderTexture _backgroundV;
+		
+		Wormhole _wormhole;
 };
 };
 
 

+ 1 - 1
src/Triangles.cpp

@@ -263,7 +263,7 @@ int Triangles::run(unsigned count)
 	
 	
 	if(_context.running)
 	if(_context.running)
 	{
 	{
-		Echo::out(Echo::Empty, "Triangles version -1.0.0.0");
+		Echo::out(Echo::Empty, "Triangles version -0.9.9");
 		Echo::out(Echo::Empty, "Copyright (C) 2016 POSITIVE MENTAL ATTITUDE");
 		Echo::out(Echo::Empty, "Copyright (C) 2016 POSITIVE MENTAL ATTITUDE");
 		Echo::out(Echo::Empty, "This program comes with ABSOLUTELY NO WARRANTY;");
 		Echo::out(Echo::Empty, "This program comes with ABSOLUTELY NO WARRANTY;");
 		Echo::out(Echo::Empty, "This is free software, and you are welcome to redistribute it");
 		Echo::out(Echo::Empty, "This is free software, and you are welcome to redistribute it");

+ 3 - 3
src/TrianglesWindow.cpp

@@ -151,15 +151,15 @@ const sf::View& TrianglesWindow::getDefaultView()
 void TrianglesWindow::open()
 void TrianglesWindow::open()
 {
 {
 	sf::ContextSettings settings;
 	sf::ContextSettings settings;
-	settings.majorVersion = 4;
-	settings.minorVersion = 5;
+	settings.majorVersion = 3;
+	settings.minorVersion = 0;
 	//settings.antialiasingLevel = 8;
 	//settings.antialiasingLevel = 8;
 	_window.create(sf::VideoMode(_size.x, _size.y), _title, (_context->fullscreen ? sf::Style::Fullscreen : (_context->borderless ? sf::Style::None : (sf::Style::Titlebar | sf::Style::Close))), settings);
 	_window.create(sf::VideoMode(_size.x, _size.y), _title, (_context->fullscreen ? sf::Style::Fullscreen : (_context->borderless ? sf::Style::None : (sf::Style::Titlebar | sf::Style::Close))), settings);
 	_window.setKeyRepeatEnabled(false);
 	_window.setKeyRepeatEnabled(false);
 	if(_context->borderless)
 	if(_context->borderless)
 		_window.setPosition(sf::Vector2i(0, 0));
 		_window.setPosition(sf::Vector2i(0, 0));
 	if(_context->vsync)
 	if(_context->vsync)
-		_window.setVerticalSyncEnabled(true);
+		_window.setFramerateLimit(60);//_window.setVerticalSyncEnabled(true);
 	if(_context)
 	if(_context)
 		_context->needsUpdate = true;
 		_context->needsUpdate = true;
 }
 }

+ 51 - 0
src/Wormhole.cpp

@@ -0,0 +1,51 @@
+#include "Utility.hpp"
+#include "Wormhole.hpp"
+
+Wormhole::Wormhole(): _light(std::make_shared<ltbl::LightPointEmission>())
+{
+	_light->_emissionSprite.setColor(sf::Color::White);
+	_light->_localCastCenter = sf::Vector2f(0.0f, 0.0f);
+}
+
+void Wormhole::load(const sf::Texture& texture1, const sf::Texture& texture2)
+{
+	_sprite.setTexture(texture1);
+	_sprite.setOrigin(sf::Vector2f(texture1.getSize() / 2u));
+	
+	_light->_emissionSprite.setTexture(texture2);
+	_light->_emissionSprite.setOrigin(sf::Vector2f(texture2.getSize() / 2u));
+}
+
+Wormhole::~Wormhole()
+{
+	Echo::debug("Deleting a wormhole.");
+}
+
+void Wormhole::update(sf::Time delta)
+{
+	float degree = delta.asSeconds() * 36.f;
+	_sprite.rotate(degree);
+	_light->_emissionSprite.rotate(degree);
+}
+
+void Wormhole::setPosition(sf::Vector2f position)
+{
+	_sprite.setPosition(position);
+	_light->_emissionSprite.setPosition(position);
+}
+
+void Wormhole::setPosition(float x, float y)
+{
+	setPosition(sf::Vector2f(x, y));
+}
+
+std::shared_ptr<ltbl::LightPointEmission>& Wormhole::light()
+{
+	return _light;
+}
+
+void Wormhole::draw(sf::RenderTarget& target, sf::RenderStates states) const
+{
+	target.draw(_sprite);
+}
+

+ 31 - 0
src/Wormhole.hpp

@@ -0,0 +1,31 @@
+#pragma once
+
+#include <SFML/Graphics.hpp>
+#include <memory>
+#include "ltbl/lighting/LightPointEmission.h"
+
+/**
+ * @class Wormhole
+ * @author POSITIVE MENTAL ATTITUDE
+ * @date 06/13/16
+ * @file Wormhole.hpp
+ * @brief A pretty independent class managing that wormhole.
+ */
+class Wormhole: public sf::Drawable
+{
+	public:
+		Wormhole();
+		virtual ~Wormhole();
+		void load(const sf::Texture& texture1, const sf::Texture& texture2);
+		void update(sf::Time delta);
+		void setPosition(sf::Vector2f position);
+		void setPosition(float x, float y);
+		sf::Vector2f getPosition();
+		std::shared_ptr<ltbl::LightPointEmission>& light();
+
+	private:
+		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
+		sf::Sprite _sprite;
+		std::shared_ptr<ltbl::LightPointEmission> _light;
+};
+