Ejemplo n.º 1
0
void OnMouseUp(thor::ActionContext<std::string> context)
{
	emitter.setParticlePosition(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
	if (selected_rune == 1)
	{
		// Build color gradient
		thor::ColorGradient gradient;
		gradient[0.f] = sf::Color::Yellow;
		gradient[0.5f] = sf::Color::Red;
		gradient[1.f] = sf::Color::Black;

		// Create color and fade in/out animations
		thor::ColorAnimation colorizer(gradient);
		thor::FadeAnimation fader(0.1f, 0.1f);

		particle_system.clearAffectors();
		// Add particle affectors
		particle_system.addAffector(thor::AnimationAffector(colorizer));
		particle_system.addAffector(thor::AnimationAffector(fader));
		particle_system.addAffector(thor::TorqueAffector(100.f));

		emitter.setParticlePosition(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
		emitter.setParticleVelocity(thor::Distributions::circle(sf::Vector2f(0.0f, 0.0f), 100.f));
		emitter.setEmissionRate(50.0f);
		particle_system.addEmitter(thor::refEmitter(emitter), sf::seconds(0.35f));
	}
	else if (selected_rune == 2)
	{
		// Build color gradient
		thor::ColorGradient gradient;
		gradient[0.f] = sf::Color::Blue;
		gradient[0.5f] = sf::Color::Black;
		gradient[1.f] = sf::Color::Black;

		// Create color and fade in/out animations
		thor::ColorAnimation colorizer(gradient);
		thor::FadeAnimation fader(0.1f, 0.1f);

		particle_system.clearAffectors();
		// Add particle affectors
		particle_system.addAffector(thor::AnimationAffector(colorizer));
		particle_system.addAffector(thor::AnimationAffector(fader));
		particle_system.addAffector(thor::TorqueAffector(100.f));

		emitter.setParticlePosition(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
		emitter.setParticleVelocity(thor::Distributions::deflect(sf::Vector2f(0.0f, -100.0f), 90.0f));
		emitter.setEmissionRate(100.0f);
		particle_system.addEmitter(thor::refEmitter(emitter), sf::seconds(0.35f));
	}
	else if (selected_rune == 3)
	{
		// Build color gradient
		thor::ColorGradient gradient;
		gradient[0.f] = sf::Color::Green;
		gradient[0.5f] = sf::Color::Cyan;
		gradient[1.f] = sf::Color::Black;

		// Create color and fade in/out animations
		thor::ColorAnimation colorizer(gradient);
		thor::FadeAnimation fader(0.1f, 0.1f);

		particle_system.clearAffectors();
		// Add particle affectors
		particle_system.addAffector(thor::AnimationAffector(colorizer));
		particle_system.addAffector(thor::AnimationAffector(fader));
		particle_system.addAffector(thor::TorqueAffector(100.f));

		emitter.setParticlePosition(window.mapPixelToCoords(sf::Mouse::getPosition(window)));
		emitter.setParticleVelocity(thor::Distributions::rect(sf::Vector2f(0.0f, 0.0f), sf::Vector2f(100.0f, 100.0f)));
		emitter.setEmissionRate(150.0f);
		particle_system.addEmitter(thor::refEmitter(emitter), sf::seconds(2.0f));
	}
	else if (selected_rune == 4)
	{
		// Build color gradient
		thor::ColorGradient gradient;
		gradient[0.f] = sf::Color::Magenta;
		gradient[0.5f] = sf::Color::Green;
		gradient[1.f] = sf::Color::Black;

		// Create color and fade in/out animations
		thor::ColorAnimation colorizer(gradient);
		thor::FadeAnimation fader(0.1f, 0.1f);

		particle_system.clearAffectors();
		// Add particle affectors
		particle_system.addAffector(thor::AnimationAffector(colorizer));
		particle_system.addAffector(thor::AnimationAffector(fader));
		particle_system.addAffector(thor::TorqueAffector(100.f));
		emitter.setParticleVelocity(thor::Distributions::circle(sf::Vector2f(0.0f, 0.0f), 250.0f));
		emitter.setEmissionRate(500.0f);
		particle_system.addEmitter(thor::refEmitter(emitter), sf::seconds(1.0f));
	}
}
Ejemplo n.º 2
0
	MainMenu() : system(TextureManager::instance().getTexture("assets/rticle.png"))
	{
		pointer.setTexture(TextureManager::instance().getTexture("assets/two_pointer.png"));
		//pointer.setPosition(1183, 427);

		//system = new thor::ParticleSystem();

		emitter.setEmissionRate(0.5f);
		emitter.setParticleLifetime( sf::seconds(40) );

		emitter.setParticleRotation( thor::Distributions::uniform(0.f, 360.f) );
		emitter.setParticlePosition( sf::Vector2f(1260,740) );
		emitter.setParticleScale(sf::Vector2f(0.1,0.1));

		system.addEmitter(thor::refEmitter(emitter));

		thor::ColorGradient gradient;
		gradient[0.0f] = sf::Color::Magenta;
		gradient[0.1f] = sf::Color::Red;
		gradient[0.2f] = sf::Color::Blue;
		gradient[0.3f] = sf::Color::Cyan;
		gradient[0.4f] = sf::Color::Green;
		gradient[0.5f] = sf::Color::Red;
		gradient[0.6f] = sf::Color::Magenta;
		gradient[0.7f] = sf::Color::Cyan;
		gradient[0.8f] = sf::Color::Red;
		gradient[0.9f] = sf::Color::Blue;
		gradient[1.0f] = sf::Color::Red;

		thor::ColorAnimation colorizer(gradient);
		thor::FadeAnimation fader(0.1f, 0.1f);

		system.addAffector( thor::ScaleAffector(sf::Vector2f(0.1f,0.1)));	
		system.addAffector( thor::AnimationAffector(fader) );
		system.addAffector( thor::AnimationAffector(colorizer) );

		sprite = AnimatedSprite(sf::seconds(0.3));

		v.setTexture(TextureManager::instance().getTexture("assets/one_upper.png"));
		back2.setTexture(TextureManager::instance().getTexture("assets/two_menu.png"));
		logo.setTexture(TextureManager::instance().getTexture("assets/one_logo.png"));
		press.setTexture(TextureManager::instance().getTexture("assets/one_anybutton.png"));
		anim.setSpriteSheet(TextureManager::instance().getTexture("assets/one_animooted.jpg"));

		for (int i = 0; i < 5; i++)
		{
			anim.addFrame(sf::IntRect(0, 800 * i, WIDTH, HEIGHT));
		}

		sprite.setAnimation(anim);
		sprite.setLooped(true);
		sprite.play();

		logo.setColor(sf::Color(255,255,255,0));
		press.setColor(sf::Color(255,255,255,0));
		pointer.setColor(sf::Color(255,255,255,0));
		press.setPosition(WIDTH/2 - press.getTextureRect().width/2, HEIGHT/2 - press.getTextureRect().height/2 + 100);
		pressFading = true;

		newLogoY = 800;
		oTweener.addTween(&CDBTweener::TWEQ_BACK, CDBTweener::TWEA_INOUT, 2.f, &newLogoY, 0.0f);

		first = true;

		pressFactor = 0.2;
		transition = false;
		check = false;
		
		sm.init(sf::Vector2f(WIDTH, HEIGHT));
		rt.create(WIDTH, HEIGHT);

		MusicManager::instance().playMusicFast("low");

		selection = 1;
	};