コード例 #1
0
    sf::Sound * SoundsManager::createMusic(sf::Uint8 ID)
    {
        music.setBuffer(buffers[ID]);
        music.setVolume(buffers[ID].defaultVolume * static_cast<float>(musicVolume) / 100.f);

        return &music;
    }
コード例 #2
0
ファイル: main.cpp プロジェクト: lupuchard/gamebase
void resetGame() {
	std::cout << player.z << " " << tunnel.getLength() - 1 << std::endl;
	if (player.z > tunnel.getLength() - 2 && player.score >= 5) difficulty++;
	tunnel.reset((difficulty + 2) * 100, difficulty);
	player.reset();
	renderer.reset();
	rockZ = ROCK_START_Z;
	rockVel = ROCK_START_VEL;
	musicSound.setPlayingOffset(sf::Time::Zero);
	musicSound.play();
	feetSound.play();
}
コード例 #3
0
ファイル: Player.cpp プロジェクト: Crowmoore/T.E.A.R
//Check player's health and start playing the heartbeat sound if bellow 20. If at 0 or below, player is dead and it's velocity is set to 0.
void Player::checkHealth(sf::Sound &heartbeat) {
	if (this->health <= 20 && this->isDying == false) {
		heartbeat.setLoop(true);
		heartbeat.play();
		this->isDying = true;
	}
	if (this->health <= 0) {
	this->health = 0;
	this->alive = false;
	this->velocity = sf::Vector2f(0, 0);
	}
}
コード例 #4
0
	void init() {
		m_first_trip = false;
		m_current_state = IDLE;

		getBody()->GetFixtureList()->SetUserData("Checkpoint");
		getBody()->SetUserData(this);

		//Load Texture
		s_texture = "Assets/Game/cp_ps.png";
		m_text_size = sf::Vector2u(42, 94);
		m_sprite.setTexture(ResourceManager<sf::Texture>::instance()->get(s_texture));
		m_sprite.setOrigin(m_text_size.x / 2, m_text_size.y / 2);
		m_sprite.setPosition(vHelper::toSF(getBody()->GetPosition()));

		addFrames(frame_idle,	0, 0, 1, 42, 94, 1.0f);
		addFrames(frame_trip,	1, 0, 5, 42, 94, 1.0f);
		addFrames(frame_active, 2, 0, 3, 42, 94, 1.0f);

		m_animator.addAnimation(IDLE,	frame_idle,		sf::seconds(1.0f));
		m_animator.addAnimation(TRIP,	frame_trip,		sf::seconds(0.4f));
		m_animator.addAnimation(ACTIVE, frame_active,	sf::seconds(0.3f));

		//Load Audio
		s_noise = "Assets/Audio/Game/cp.wav";
		m_noise.setBuffer(ResourceManager<sf::SoundBuffer>::instance()->get(s_noise));
	}
コード例 #5
0
ファイル: Textbox.cpp プロジェクト: afly6899/LustrousLegacy
	Textbox::Textbox(std::map<std::string, sf::Sprite>& faceMap, const sf::Font& font, sf::Sound& bleep, int width_box, int height_box, bool block, int font_size, int padding) :
		faceMap(faceMap), width(width_box), height(height_box), bleep(bleep), block_draw(block), padding(padding) {
		
		displayText.setFont(font);
		displayText.setCharacterSize(font_size);
		displayText.setColor(sf::Color::White);
		
		bleep.setPitch(2);
		if (!block_draw)
		{
			faceSprite.setTextureRect(sf::IntRect(0, 0, faceSprite.getLocalBounds().width, faceSprite.getLocalBounds().height));
			faceSprite.setOrigin(faceSprite.getLocalBounds().width*.5, faceSprite.getLocalBounds().height*.5);
			faceSprite2.setTextureRect(sf::IntRect(0, 0, faceSprite2.getLocalBounds().width, faceSprite2.getLocalBounds().height));
			faceSprite2.setOrigin(faceSprite2.getLocalBounds().width*.5, faceSprite2.getLocalBounds().height*.5);
			rectText.setSize(sf::Vector2f(width - padding, height*.3));
			rectText.setOrigin((width - padding)*.5, height*.5);
			rectText.setFillColor(sf::Color::Black);
			rectText.setOutlineColor(sf::Color::White);
			rectText.setOutlineThickness(2);
			actorName.setColor(sf::Color::Yellow);
			actorName.setFont(font);
		}
		else {
			rectText.setSize(sf::Vector2f(width, height));
			rectText.setOrigin(width*.5, height*.5);
		}	
	}
コード例 #6
0
	/**
	*	@brief 
	*/
	void trip() override {
		setTrip(true);

		m_first_trip = true;
		m_noise.play();
		m_current_state = TRIP;
		m_animator.playAnimation(TRIP);
	}
コード例 #7
0
ファイル: ToneAlarm_SF.cpp プロジェクト: KIrill-ka/ardupilot
void ToneAlarm_SF::set_buzzer_tone(float frequency, float volume, float duration_ms)
{
    if (frequency <= 0) {
        return;
    }

    Synth::sTone tone;
    tone.waveType = Synth::OSC_SQUARE;
    tone.dStartFrequency = frequency;
    tone.dEndFrequency = frequency;
    tone.dAmplitude = 1;

    envelope.dSustainTime = duration_ms/1000.0f;

    Synth::generate(&soundBuffer, envelope, tone, 20000, 44100);
    demoSound.setBuffer(soundBuffer);
    demoSound.play();
}
コード例 #8
0
ファイル: Sound1.cpp プロジェクト: laurensvr/TI3A-AI
void rawGenerator::playStream()
{
	if (sw == 0){
		if (!Buffer.loadFromSamples(waveOut, SAMPLES, 1, 44100)) {
			std::cerr << "Loading failed!" << std::endl;
			//return 1;
		}
		std::cout << "Sound 1" << std::endl;
		sw = 0;
	}


	Sound.setBuffer(Buffer);
	//Sound.setLoop(true);
	Sound.play();


}
コード例 #9
0
 void play_sound(sf::Sound& sound, const SoundSample& sample, const PlaybackProperties& properties, bool looped)
 {
   sound.setBuffer(sample);
   sound.setPitch(properties.pitch);
   sound.setAttenuation(properties.attenuation);
   sound.setLoop(looped);
   sound.setRelativeToListener(properties.relative_to_listener);
   sound.setMinDistance(properties.min_distance);
   sound.setVolume(properties.volume * 100.0f);
   sound.play();
 }
コード例 #10
0
ファイル: menu.cpp プロジェクト: TarasJan/Sleepwalker
	virtual void init()
	
	
	{
		dt=0;
		select_switch = 0.2;
		
		if (!standard_font.loadFromFile("fonts/Unique.ttf"))
{
    // error...
}
	//	darken = sf::RectangleShape(sf::Vector2f(800,400));
		
//sfx
if (!buffer.loadFromFile("sfx/Blip 007.wav"))

{
     //error
}
blip.setBuffer(buffer);


		if(!title.loadFromFile("gfx/title.png"))std::cout<<"Error"<<std::endl;

		t**s.setTexture(title);
		t**s.setOrigin(50,8);
		t**s.setScale(sf::Vector2f(3,3));
		t**s.setPosition(400,100);
		
		sf::FloatRect tempt ;
		
		for(int i =0 ; i<4;i++)
		{
			selector[i].setFont(standard_font);
			selector[i].setCharacterSize(28);
			 
		
		// dla centrowania obiektow
		
			tempt = selector[i].getGlobalBounds();
			selector[i].setOrigin(sf::Vector2f(tempt.width/2,tempt.height/2));
			
			selector[i].setPosition(350,150+30*i);
		}
		
		selector[0].setString("Start game");
		selector[1].setString("Info");
		selector[2].setString("Highscores");
		selector[3].setString("Exit");
		
		
		selector[0].setColor(sf::Color(0,127,127));
		
		timer.restart();
		
		};
コード例 #11
0
ファイル: main.cpp プロジェクト: licnep/RangoShooter
void handleMouseKeypress(int key, int state, int x, int y)
{
    switch (key) {
		case GLUT_LEFT_BUTTON:
            if (state == 0 && pause==FALSE){
                if (gun0.bullet_number > 0) {
					gun0.bullet_number--;
					pistola.pushAnimation(animation(locRot(0,0,0,10,0,-10),100,std::chrono::system_clock::now()));
					pistola.pushAnimation(animation(locRot(0,0,0,-10,0,10),100,std::chrono::system_clock::now()+std::chrono::milliseconds(100)));
                    collisionCurse();
                }
				else 
				{
					sound.setBuffer(sound_youreempty);
					sound.play();
				}
            }
            break;
    }
}
コード例 #12
0
ファイル: Enemy_1.cpp プロジェクト: niyazm/2DShooter
void Enemy::isdead(Enemy &foe,sf::Sound &death)
{
	if (foe.health <= 0)
	{
		if (active == true)
		{
			death.play();
		}
		active = false;
		foe.enemy.setPosition(-900, -100);
	}
}
コード例 #13
0
ファイル: Player.cpp プロジェクト: Crowmoore/T.E.A.R
//Check the player's ammoDescription, create and initialize bullets accordinly. Push the created bullet to the bullets vector.
void Player::shoot(sf::RenderWindow &window, vector <Bullet *> &bullets, sf::Sound &laser) {
	if(this->ammoDescription == "Red Rays of Happiness") {
		Bullet *bullet = new Bullet(this->getPosition(), (sf::Vector2f) (window.mapPixelToCoords(sf::Mouse::getPosition(window))), sf::Color::Red, "player");
		bullet->setDamage(this->damage);
		bullet->setVelocity(sf::Vector2f(12, 12));
		bullet->setScale(0.3, 0.3);
		bullet->calculateRotation(window);
		bullet->calculateDirection(window);
		laser.play();
		bullets.push_back(bullet);
	}
	if (this->ammoDescription == "Green Beams of Hurting") {
		Bullet *bullet = new Bullet(this->getPosition(), (sf::Vector2f) (window.mapPixelToCoords(sf::Mouse::getPosition(window))), sf::Color::Green, "player");
		bullet->setDamage(this->damage);
		bullet->setVelocity(sf::Vector2f(14, 14));
		bullet->setScale(0.4, 0.4);
		bullet->calculateRotation(window);
		bullet->calculateDirection(window);
		laser.play();
		bullets.push_back(bullet);
	}
}
コード例 #14
0
                                        Entity(sf::Texture& sTexture, EntityType type, Collidable::Type colType, sf::SoundBuffer& soundBuf1, sf::SoundBuffer& soundBuf2)
                                        : Collidable(colType)
                                        , mSprite(sTexture)
                                        , mDeathSound(soundBuf1)
                                        , mLaserSound(soundBuf2)
                                        , mType(type)
                                        , mCollected(0)
                                        , mFireProjectile(false)
                                        , mFireCountdown(sf::Time::Zero)
                                        {
                                            sf::FloatRect bounds = mSprite.getLocalBounds();
                                            mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);

                                            switch(type)
                                            {
                                                case EntityType::Player: mHitPoints = PlayerHitPoints; break;
                                                case EntityType::Enemy: mHitPoints = EnemyHitPoints; break;
                                                default: break;
                                            }

                                            mLaserSound.setVolume(75.f);
                                            mDeathSound.setVolume(75.f);
                                        };
コード例 #15
0
ファイル: Tut22.cpp プロジェクト: CodingMadeEasy/Sfml-1.6
void Collision(sf::RenderWindow &Window, sf::Sound &collision, sf::Shape player, sf::Shape &object)
{
    if(player.GetPosition().x + PLAYERWIDTH < object.GetPosition().x ||
       player.GetPosition().x > object.GetPosition().x + OBJECTWIDTH ||
       player.GetPosition().y + PLAYERHEIGHT < object.GetPosition().y ||
       player.GetPosition().y > object.GetPosition().y + OBJECTHEIGHT)
    {
        // No Collision
    }
    else
    {
        collision.Play();
        object.SetPosition(rand() % (ScreenWidth - OBJECTWIDTH), rand() % (ScreenHeight - OBJECTHEIGHT));
    }
}
コード例 #16
0
ファイル: Player.cpp プロジェクト: niyazm/2DShooter
bool Player::isdead(Player &character,sf::Sound &death, sf::RectangleShape &Lifebar)
{
	deadimg.loadFromFile(resourcePath() + "deadplayer.png");
	if(character.health <= 0)
	{
		if(character.active == true)
		{
			death.play();
		}
		character.player.setTexture(deadimg);
		character.active = false;
        Lifebar.setSize(sf::Vector2f(0,0));
	}

	return character.active;
}
コード例 #17
0
void Kolizja(Swoj &player, Obcy &wrog, sf::Sound &kolizja, int &punkty, int &zycia){

    if((player.pobierzX() < wrog.pobierzX() + SZEROBIEKTU &&
		player.pobierzX() > wrog.pobierzX() &&
		player.pobierzY() + WYSGRACZ/2 > wrog.pobierzY() &&
		player.pobierzY() + WYSGRACZ/2 < wrog.pobierzY() + WYSOOBIEKTU)
			||
		(player.pobierzX() + SZERGRACZ > wrog.pobierzX() &&
		player.pobierzX() + SZERGRACZ < wrog.pobierzX() + SZEROBIEKTU &&
		player.pobierzY() + WYSGRACZ/2 > wrog.pobierzY() &&
		player.pobierzY() + WYSGRACZ/2 < wrog.pobierzY() + WYSOOBIEKTU)	
			||
		(player.pobierzX() + SZERGRACZ/2 > wrog.pobierzX() &&
		player.pobierzX() + SZERGRACZ/2 < wrog.pobierzX() + SZEROBIEKTU &&
		player.pobierzY() > wrog.pobierzY() &&
		player.pobierzY() + WYSGRACZ < wrog.pobierzY() + WYSOOBIEKTU))
	{
		kolizja.Play();
		player.x = player.startX;
		player.y = player.startY;
		--zycia;
	} else {
		if(player.pobierzX() + SZERGRACZ/2 > wrog.pobierzX() - 5 &&
			player.pobierzX() + SZERGRACZ/2 < wrog.pobierzX() + SZEROBIEKTU + 5 &&
			player.pobierzY() + WYSGRACZ > wrog.pobierzY()	&&
			player.pobierzY() < wrog.pobierzY() + WYSOOBIEKTU)
		{
			player.ZmusDoSkoku();
			
			if(typeid(wrog) == typeid (Wrog)){
				++punkty;
			} else if(typeid(wrog) == typeid (Wrog_Lewy)){
				punkty +=5;
			} else 
				punkty +=10;
		}
	}
}
コード例 #18
0
ファイル: main.cpp プロジェクト: lupuchard/gamebase
// Program entry point
int main(int argc, char ** argv) {
	titleImg.loadFromFile("assets/title.png");

	sf::SoundBuffer sb;
	sb.loadFromFile("assets/avalanche.ogg");
	boulderSound.setBuffer(sb);
	boulderSound.setLoop(true);
	boulderSound.play();

	sf::SoundBuffer sb2;
	sb2.loadFromFile("assets/death.ogg");
	fallingSound.setBuffer(sb2);
	fallingSound.setRelativeToListener(true);

	sf::SoundBuffer sb3;
	sb3.loadFromFile("assets/jump.wav");
	jumpingSound.setBuffer(sb3);
	jumpingSound.setRelativeToListener(true);

	sf::SoundBuffer sb4;
	sb4.loadFromFile("assets/POL-flash-run-short.wav");
	musicSound.setBuffer(sb4);
	musicSound.setRelativeToListener(true);
	musicSound.setVolume(15.f);
	musicSound.setLoop(true);
	musicSound.play();

	sf::SoundBuffer sb5;
	sb5.loadFromFile("assets/footsteps.ogg");
	feetSound.setRelativeToListener(true);
	feetSound.setBuffer(sb5);
	feetSound.setLoop(true);
	feetSound.setVolume(50);
	feetSound.play();

	sf::SoundBuffer sb6;
	sb6.loadFromFile("assets/bump.ogg");
	bumpSound.setRelativeToListener(true);
	bumpSound.setBuffer(sb6);
	bumpSound.setVolume(40);

	sf::SoundBuffer sb7;
	sb7.loadFromFile("assets/gem.ogg");
	gemSound.setRelativeToListener(true);
	gemSound.setBuffer(sb7);
	gemSound.setVolume(60);

	sf::SoundBuffer sb8;
	sb8.loadFromFile("assets/Powerup3.wav");
	powerSound.setRelativeToListener(true);
	powerSound.setBuffer(sb8);
	powerSound.setVolume(80);

	sf::SoundBuffer sb9;
	sb9.loadFromFile("assets/alert.ogg");
	alertSound.setRelativeToListener(true);
	alertSound.setBuffer(sb9);
	//powerSound.setVolume(80);

    // Create the SFML window
	window.create(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "A Bolder Escape");

    while (window.isOpen()) {
		events();
		if (!menu) logic();
		render();
    }

    return 0;
}
コード例 #19
0
ファイル: menu.cpp プロジェクト: TarasJan/Sleepwalker
	virtual void update(){
		
		sf::Event event;
        while (window->pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
            
            {
                window->close();
                has_ended = true;
                }
             
             if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
             
             {
				// has_ended = true;
				 
			 }
             
             if (dt > select_switch && event.type == sf::Event::KeyReleased )
             
             {
				
			if (	 event.key.code == sf::Keyboard::Up)
			
			{
				
						if(selector[0].getColor() == sf::Color(0,127,127))
					
					{
						selector[0].setColor(sf::Color(255,255,255)) ;
						selector[3].setColor(sf::Color(0,127,127)) ;
						
					}
					
					else
					
					{
				
				
				for(int i =1;i<4;i++)
					{
						if(selector[i].getColor() == sf::Color(0,127,127))
						{
							selector[i].setColor(sf::Color(255,255,255)) ;
							selector[i-1].setColor(sf::Color(0,127,127)) ;
							break;
							
						}
						
					}
			
			}
				
				 blip.play();
				 dt=0;
				 timer.restart();
				
			}
			
			if (	 event.key.code == sf::Keyboard::Down)
				
				{
					
					if(selector[3].getColor() == sf::Color(0,127,127))
					
					{
						selector[3].setColor(sf::Color(255,255,255)) ;
						selector[0].setColor(sf::Color(0,127,127)) ;
						
					}
					
					else
					{
					
					for(int i =0;i<3;i++)
					{
						if(selector[i].getColor() == sf::Color(0,127,127))
						{
							selector[i].setColor(sf::Color(255,255,255)) ;
							selector[i+1].setColor(sf::Color(0,127,127)) ;
							break;
							
						}
						
					}
					
				}
					
				 blip.play();
				 dt=0;
				 timer.restart();
			}
				
            
                
			}
		
	
	
	
	 if (dt > select_switch && event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Return)
             
             {
				blip.play();
				dt=0;
				while(!dt>select_switch) dt = timer.getElapsedTime().asSeconds();
				
             if(selector[3].getColor() == sf::Color(0,127,127))
             {
                window->close();
                *selection_pointer = 15;
                has_ended = true;
			 }
			 
			if(selector[0].getColor() == sf::Color(0,127,127))
             {
				*selection_pointer = 12;
                has_ended = true;
			 }
			 if(selector[1].getColor() == sf::Color(0,127,127))
             {
				  has_ended = true;
				*selection_pointer = 1;

			 }
			 if(selector[2].getColor() == sf::Color(0,127,127))
             {
				  has_ended = true;
				*selection_pointer = 2;

			 }
			 
                
			}
		
	}
	

		
		dt = timer.getElapsedTime().asSeconds();
		

		
		};
コード例 #20
0
ファイル: SoundFx.hpp プロジェクト: kurtjd/space-invaders
 sf::SoundSource::Status getStatus(){ return sound.getStatus(); }
コード例 #21
0
ファイル: main.cpp プロジェクト: lupuchard/gamebase
void logic() {
	sf::Time newTime = mainClock.getElapsedTime();
	sf::Time diff = newTime - prevTime;
	prevTime = newTime;
	float difff = diff.asMicroseconds() / 1000000.f;

	player.slowTime -= difff;
	if (player.slowTime > 1) difff /= player.slowTime;
	player.feather -= difff;
	if (player.feather < 0.0f && player.hasFeather) {
		sf::Text txt("Lavawalk expired", renderer.getFont());
		txt.setColor(sf::Color(255, 255, 0, 255));
		txt.setCharacterSize(36);
		renderer.addStatusText(txt);
		player.hasFeather = false;
		alertSound.play();
	}
	float difff2 = (difff + diff.asMicroseconds() / 1000000.f) / 2;

	int z1 = std::floor(player.z + 1.3);
	int z2 = std::floor(player.z + 0.9);
	int x1 = std::floor(player.x + 2.1);
	int x2 = std::floor(player.x + 1.9);

	if (rockZ > tunnel.getLength() - 1 && tunnel.hasBrickWall()) {
		//destroy bricks
		for (float i = -2; i <= 2; i += 0.1f) {
			for (float j = -2; j <= 2; j += 0.1f) {
				renderer.addParticles(1, sf::Color(108, 7, 7), sf::Vector3f(i, j, tunnel.getLength()));
			}
		}
		tunnel.breakWall();
	}

	if (player.fallen) {
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return)) {
			resetGame();
		}
		feetSound.stop();
		player.zVel -= difff * 10;
		if (player.zVel < 0) player.zVel = 0;

		if (rockZ > player.z) {
			static float parts = 0;
			parts += difff * 20;
			while(parts > 0) {
				renderer.addParticles(1, sf::Color(100, 50, 10), sf::Vector3f(rand() / (float)RAND_MAX * 2 - 1, 2, rockZ + 2));
				parts--;
			}
		}
	} else if (rockZ > player.z) {
		player.fallen = true;
		fallingSound.play();
		musicSound.pause();
		renderer.addParticles(10, sf::Color(255, 0, 0), sf::Vector3f(player.x, 2, player.z));
		player.y = -100;
	} else if (!(player.feather > 0) && (player.y < 0.01 && (tunnel.get(z1, x1) == 1 && tunnel.get(z2, x1) == 1 && tunnel.get(z1, x2) == 1 && tunnel.get(z2, x2) == 1))) {
		player.fallen = true;
		fallingSound.play();
		musicSound.pause();
		renderer.addParticles(10, sf::Color(255, 127, 0), sf::Vector3f(player.x, 3, player.z));

		/*
		sf::Text txt("Fail!", renderer.getFont());
		txt.setColor(sf::Color(255, 0, 0, 255));
		txt.setCharacterSize(36);
		renderer.addStatusText(txt);
		*/
	} else {
		if (!player.fallen && player.y < 0.3 && (tunnel.get(z1, x1) > 1 && tunnel.get(z2, x1) > 1 && tunnel.get(z1, x2) > 1 && tunnel.get(z2, x2) > 1)) {
			int rok = tunnel.get(z1, x1);
			if (rok != 5) {
				if (rok == 2)
					player.zVel = 1.5;
				else if (rok == 3)
					player.zVel = 3.5f;
				else if (rok == 4)
					player.zVel = 0.0f;
				bumpSound.play();
				tunnel.set(z1, x1, 0);
				renderer.addParticles(10, sf::Color(100, 100, 100), sf::Vector3f(player.x, 2, player.z));
			}
		} else if (!player.fallen && player.y > 0.3 && (tunnel.get(z1, x1 + 5) >= 1 && tunnel.get(z2, x1 + 5) >= 1 && tunnel.get(z1, x2 + 5) >= 1 && tunnel.get(z2, x2 + 5) >= 1)) {
			int gem = tunnel.get(z1, x1 + 5);
			if (gem <= 3) {
				player.score += gem;
				gemSound.play();
				if (gem == 1) {
					renderer.addParticles(5, sf::Color(200, 0, 0), sf::Vector3f(player.x, .5, player.z + 1));

					sf::Text txt("Ruby: +1", renderer.getFont());
					txt.setColor(sf::Color(255, 0, 0, 255));
					txt.setCharacterSize(36);
					renderer.addStatusText(txt);
				} else if (gem == 2) {
					renderer.addParticles(5, sf::Color(0, 255, 0), sf::Vector3f(player.x, .5, player.z + 1));

					sf::Text txt("Emerald: +2", renderer.getFont());
					txt.setColor(sf::Color(0, 255, 0, 255));
					txt.setCharacterSize(36);
					renderer.addStatusText(txt);
				} else if (gem == 3) {
					renderer.addParticles(5, sf::Color(0, 255, 255), sf::Vector3f(player.x, .5, player.z + 1));

					sf::Text txt("Diamond: +3", renderer.getFont());
					txt.setColor(sf::Color(0, 255, 255, 255));
					txt.setCharacterSize(36);
					renderer.addStatusText(txt);
				}
			} else if (gem == 4) {
				player.slowTime = 10;
				powerSound.play();

				sf::Text txt("Slow Time acquired", renderer.getFont());
				txt.setColor(sf::Color(192, 0, 255, 255));
				txt.setCharacterSize(36);
				renderer.addStatusText(txt);
			} else if (gem == 5) {
				for (int i = 5; i < 9; i++) {
					for (int j = z1 + 1; j <= z1 + 6; j++) {
						if (j >= tunnel.getLength()) break;
						if (tunnel.get(j, i) == 0) tunnel.set(j, i, 1);
					}
				}
				powerSound.play();

				sf::Text txt("Rain Rubies acquired", renderer.getFont());
				txt.setColor(sf::Color(192, 0, 255, 255));
				txt.setCharacterSize(36);
				renderer.addStatusText(txt);
			} else if (gem == 6) {
				player.feather = 5;
				player.hasFeather = true;
				powerSound.play();

				sf::Text txt("Lavawalk acquired", renderer.getFont());
				txt.setColor(sf::Color(192, 0, 255, 255));
				txt.setCharacterSize(36);
				renderer.addStatusText(txt);
			}
			tunnel.set(z1, x1 + 5, 0);
		}


		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) || sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
			player.xVel -= difff * 4;
			if (player.xVel < -1) player.xVel = -1;
		} else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) || sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
			player.xVel += difff * 4;
			if (player.xVel > 1) player.xVel = 1;
		} else {
			if (player.xVel > 0) {
				if (player.xVel < difff * 3) {
					player.xVel = 0;
				} else {
					player.xVel -= difff * 3;
				}
			} else if (player.xVel < 0) {
				if (player.xVel > -difff * 3) {
					player.xVel = 0;
				} else {
					player.xVel += difff * 3;
				}
			}
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) || sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
			player.zVel += difff * 4;
			if (player.zVel > 8) player.zVel = 8;
		} else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) || sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
			player.zVel -= difff * 4;
			if (player.zVel < 3)
				player.zVel = 3;
		} else {
			if (player.zVel > 5) {
				if (player.zVel < 5 + difff * 3) {
					player.zVel = 5;
				} else {
					player.zVel -= difff * 3;
				}
			} else if (player.zVel < 5) {
				if (player.zVel > 5 - difff * 3) {
					player.zVel = 5;
				} else {
					player.zVel += difff * 3;
				}
			}
		}
		if (!player.fallen && player.y <= 0 && sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
			player.yVel = 4;
			player.y += 0.01;
			jumpingSound.play();
			feetSound.pause();
		}
	}

	if (!player.fallen && player.y < 0) {
		player.y = 0;
		player.yVel = 0;
		if (feetSound.getStatus() == sf::Sound::Status::Paused) {
			feetSound.play();
		}
	}

	player.yVel -= difff * 15;

	if (player.z > tunnel.getLength() - 2) {
		feetSound.pause();
	} else {
		player.z += player.zVel * difff * 2;
	}
	player.y += player.yVel * difff;
	player.x += player.xVel * difff2 * 2;
	if (player.x < -1.9) {
		player.x = -1.9;
		player.xVel = 0;
	}
	else if (player.x > 1.9) {
		player.x = 1.9;
		player.xVel = 0;
	}

	rockZ += difff * rockVel;
	rockVel += difff / 4;

	renderer.update(difff);

	sf::Listener::setPosition(player.x / 10, player.y / 10, player.z / 10);
	boulderSound.setPosition(0, 0, rockZ / 10 + 2);
}
コード例 #22
0
//        void                            setLaserSound(sf::SoundBuffer& sound){ mLaserSound.setBuffer(sound); mLaserSound.setVolume(50.f);}
        void                            playDeathSound(){ mDeathSound.play(); }
コード例 #23
0
void SoundEngine::playSound(sf::Sound & Sound, bool b)
{
  if (!b || (b && Sound.getStatus() != sf::Sound::Playing))
    Sound.play();
}
コード例 #24
0
ファイル: main.cpp プロジェクト: licnep/RangoShooter
void collisionCurse (void)
{
    int hitten, id;
    
    float fittX, fittY;
    
    fittX = lastx;
    fittY = windowHeight-lasty;
    
    GLuint buff[64] = {0};
 	GLint hits, view[4];
    
 	
    //This choose the buffer where store the values for the selection data
 	glSelectBuffer(64, buff);
    
 	
    //This retrieve info about the viewport
    
 	glGetIntegerv(GL_VIEWPORT, view);
    
 	
    //Switching in selecton mode
 	glRenderMode(GL_SELECT);
    
    //Clearing the name's stack
    //This stack contains all the info about the objects
 	glInitNames();
    
 	
    //Now fill the stack with one element (or glLoadName will generate an error)
 	glPushName(0);
    
 	
    //Now modify the vieving volume, restricting selection area around the cursor
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
    glLoadIdentity();
    
    
    //restrict the draw to an area around the cursor
    gluPickMatrix(fittX, fittY, 5.0, 5.0, view);
	gluPerspective(45.0,							//The camera angle
		(double)windowWidth / (double)windowHeight, //The width-to-height ratio
				   0.1,								//The near z clipping coordinate
				   200.0);							//The far z clipping coordinate
        
    glutSwapBuffers();
    display();
    
    
    glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
    
    //get number of objects drawed in that area
    //and return to render mode

 	hits = glRenderMode(GL_RENDER);
    
    id  = target_hit(hits, buff);
    
    if (id != -1 ){

        hitten = id - 100;
        if(livelli.posizione[hitten].movimento==1){
            m[hitten].stato=0;
            m[hitten].count=2;
            m[hitten].temp_rel=t.tempoi-1;
        }else if(livelli.posizione[hitten].movimento==2){
            m[hitten].stato=2;
        }    
        score += ch_index.character[ch].punteggio;
		
		//play hit sound
		if (ch_index.character[ch].punteggio>0) sound.setBuffer(sound_hit);
		else sound.setBuffer(sound_ohno);
		sound.play();

        levelChanger();
    } else {
		//play miss sound
		sound.setBuffer(sound_miss);
		sound.play();
	}
    
 	glMatrixMode(GL_MODELVIEW);
    
    return;
}
コード例 #25
0
ファイル: main.cpp プロジェクト: DevelopersGuild/bird-squad
void update(sf::RectangleShape floor[], sf::RectangleShape road[], int floorWidth, int floorHeightPosition, sf::Sprite& rrSprite, double &pos, bool &jumpStatus,
     bool& isoverlap, std::stringstream &ss, sf::Clock &clock, sf::Text &textTime, sf::Music& roadrunnerMusic, sf::Music& sanicMusic, sf::Sound& squawkSound, 
     bool& deathStatus, sf::Sprite& sanicSprite, sf::Sprite& sanicPowerupSprite, bool& sanicPowerupStatus, int& globalSpeed, sf::Time& sanicTime, bool& powerupSpawnStatus, 
     sf::Time& powerupSpawnTimer, sf::Sprite arrayOfObjectSprite[], bool& boulderSpawnStatus, int numObject, int objStop, sf::Sound& jumpSound, sf::RectangleShape backgroundbox[])
{
	//game timer
     if (!isoverlap)
	{
		sf::Time time1 = clock.getElapsedTime();
		ss.str(std::string());
		ss << setprecision(2) << fixed << static_cast<double>(time1.asSeconds());
		textTime.setString(ss.str().c_str());
	}

     // Return to roadrunner character
     if (clock.getElapsedTime() >= sanicTime && sanicPowerupStatus)
     {
          sanicMusic.pause();
          roadrunnerMusic.play();
          sanicPowerupStatus = false;
     }

     // How fast everything moves
     if (sanicPowerupStatus && (clock.getElapsedTime() <= sanicTime - sf::seconds(1)))         //sanic run speed
          globalSpeed = 100;
     else
          globalSpeed = 15;                                                                    //roadrunner run speed

     // Powerup spawner, checks every 10 seconds
     if (clock.getElapsedTime() >= powerupSpawnTimer)
     {
          powerupSpawnTimer += sf::seconds(10);                       //time to spawn for every consecutive powerup after the first
          powerupSpawnStatus = true;
     }

     // Powerup spawn chance
     if (powerupSpawnStatus)
     {
          if (rand() % 100 <= 33)                                 // 33% chance to spawn
          {
               sanicPowerupSprite.setScale(0.05, 0.05);
               sanicPowerupSprite.setPosition(floorWidth, 250);
          }
          powerupSpawnStatus = false;
     }

     // Sanicpowerup movement, how fast the icon moves
     if (sanicPowerupSprite.getPosition().x >= objStop)
          sanicPowerupSprite.move(-globalSpeed, 0);

     // Roadrunner and sanicpowerup collision
     if (overlap(rrSprite, sanicPowerupSprite) && !sanicPowerupStatus)
     {
          roadrunnerMusic.pause();
          sanicMusic.play();
          sanicPowerupStatus = true;
          sanicTime = clock.getElapsedTime() + sf::seconds(10);
          sanicPowerupSprite.setScale(0, 0);
     }

     //Infinite floor/road
     floor[0].move(-globalSpeed, 0);
     floor[1].move(-globalSpeed, 0);

     road[0].move(-globalSpeed, 0);
     road[1].move(-globalSpeed, 0);
     
     if (floor[0].getPosition().x <= -floorWidth)
	{
		floor[0].setPosition(0, floorHeightPosition);
		floor[1].setPosition(floorWidth, floorHeightPosition);

          road[0].setPosition(0, floorHeightPosition);
          road[1].setPosition(floorWidth, floorHeightPosition);
	}

     //backgroundbox, movement, infinite background
     if (sanicPowerupStatus && (clock.getElapsedTime() <= sanicTime - sf::seconds(1)))
     {
          backgroundbox[0].move(-globalSpeed / 2 + 10, 0);
          backgroundbox[1].move(-globalSpeed / 2 + 10, 0);
     }
     else
     {
          backgroundbox[0].move(-globalSpeed + 10, 0);
          backgroundbox[1].move(-globalSpeed + 10, 0);
     }

     if (backgroundbox[0].getPosition().x <= -floorWidth)
     {
          backgroundbox[0].setPosition(0, -100);
          backgroundbox[1].setPosition(floorWidth, -100);
     }
     
    
	// Roadrunner jump
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && rrSprite.getPosition().y >= 505)
	{
		jumpStatus = true;
          jumpSound.play();
	}

	if (jumpStatus && (rrSprite.getPosition().y <= 505))
	{
		rrSprite.move(0, -15);
	}

	if (rrSprite.getPosition().y <= 100)
	{
		jumpStatus = false;
	}

	if (!jumpStatus && (rrSprite.getPosition().y < 505))
	{
		rrSprite.move(0, 15);
	}

     // Sanic jump
     if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && sanicSprite.getPosition().y >= 485)
     {
          jumpStatus = true;
     }

     if (jumpStatus && (sanicSprite.getPosition().y <= 485))
     {
          sanicSprite.move(0, -15);
     }

     if (sanicSprite.getPosition().y <= 100)
     {
          jumpStatus = false;
     }

     if (!jumpStatus && (sanicSprite.getPosition().y < 485))
     {
          sanicSprite.move(0, 15);
     }

     // Movement of objects
     for (int i = 0; i < numObject-1; i++)
     {
          if (arrayOfObjectSprite[i].getPosition().x >= objStop)
               arrayOfObjectSprite[i].move(-globalSpeed, 0);
     }

     if (arrayOfObjectSprite[6].getPosition().x >= objStop)
          arrayOfObjectSprite[6].move(-globalSpeed * 1.3, 0);             // Coyote run speed

     // First checkpoint: spawns one object
     for (int i = 0; i < numObject; i++)
     {
          if ((arrayOfObjectSprite[i].getPosition().x >= 800 && arrayOfObjectSprite[i].getPosition().x <= 1000) && boulderSpawnStatus)
          {
               boulderSpawnStatus = false;
               int reroll = true;
               int randBoulderSpawn = floorWidth + 700 + rand() % 1000;

               while (reroll)
               {
                    int randBoulder = rand() % numObject;

                    if (arrayOfObjectSprite[randBoulder].getPosition().x <= objStop)
                    {
                         if (randBoulder >= 0 && randBoulder < 2)
                              arrayOfObjectSprite[randBoulder].setPosition(randBoulderSpawn, 500);            // boulder

                         else if (randBoulder >= 2 && randBoulder < 4)
                              arrayOfObjectSprite[randBoulder].setPosition(randBoulderSpawn, 420);            // cactus

                         else if (randBoulder >= 4 && randBoulder < 6)
                              arrayOfObjectSprite[randBoulder].setPosition(randBoulderSpawn, 510);            // tumbleWeed

                         else
                              arrayOfObjectSprite[randBoulder].setPosition(randBoulderSpawn+1000, 470);       // coyote, give him a running start

                         reroll = false;
                    }
               }
          }
     }

     // Second Checkpoint: renable spawning of objects
     for (int i = 0; i < numObject; i++)
     {
          if (arrayOfObjectSprite[i].getPosition().x >= 600 && arrayOfObjectSprite[i].getPosition().x < 800)
               boulderSpawnStatus = true;
     }

     // Check collision for all objects in array
     for (int i = 0; i < numObject; i++)
     {
          if (overlap(rrSprite, arrayOfObjectSprite[i]) && !sanicPowerupStatus)
          {
               isoverlap = true;
          }
     }

     // Death conditions
     if (isoverlap && deathStatus)
     {
          roadrunnerMusic.pause();
          squawkSound.play();
          deathStatus = false;

     }
     
}
コード例 #26
0
ファイル: screen_1.hpp プロジェクト: EmilyGarcia/Frogger
int screen_1::Run(sf::RenderWindow &App)
{
    hop.setBuffer(hopFile);
    trucked.setBuffer(truckedFile);
    dunked.setBuffer(dunkedFile);
    
    // Clock
    sf:: Clock clock;
    sf::Time time;
    sf::Time delay;
    
    // Plays Intro
    intro.play();
    delay = intro.getDuration();
    
    time = clock.getElapsedTime();
    // Music
    while ( clock.getElapsedTime() <= delay )
    {
        //cout << "NO";
    }
    froggerTheme.setVolume(50);
    froggerTheme.play();
    clock.restart();
    
    sf::Event Event;
    
    bool Running = true;
    int sum = 0;// for log testing purposes
    int sum2 = 0;
    int sum3 = 0;
    int sum4 = 0;
    int sum5 = 0;
    int sum6 = 0;
    int sum7 = 0;
    int sum8 = 0;
    int sum9 = 0;
    int sum10 = 0;
    
    while (Running)
    {
        // Timer Rect and Clock
        double time = clock.getElapsedTime().asSeconds();
        
        if(time >= 1.5)
        {
            timeRect.width = timeRect.width - 2.383;
            timer.setTextureRect(timeRect);
            clock.restart();
        }
        
        if(timeRect.width <= 0)
        {
            frogOnLily1 = false;
            frogOnLily2 = false;
            frogOnLily3 = false;
            frogOnLily4 = false;
            frogOnLily5 = false;
            mainPlayer.setNumLives(3);
            rectSource.width = 115;
            life.setTextureRect(rectSource);
            occupied1.setPosition(-100, -100);
            occupied2.setPosition(-100, -100);
            occupied3.setPosition(-100, -100);
            occupied4.setPosition(-100, -100);
            occupied5.setPosition(-100, -100);
            froggerTheme.pause();
            clock.restart();
            timeRect.width = 143;
            timer.setTextureRect(timeRect);
            frogger.setPosition(320, 605);
            
            return 2;
        }
        // *********************************************************************
        // Creating the objects of Object class for continuous movement
        //
        // Object(double posX, double posY, double speed)
        // *********************************************************************
        // Trucks
        Object t1(130, 420,0.2 );
        Object t2(550, 290, 0.2);
        // Cars
        Object c1(-50, 420, 0.3);
        Object c2(280, 289, 0.2);
        Object c3(0, 289, 0.2);
        // Short Logs
        Object sl1(0, 125, 0.2);
        Object sl2(200, 61, 0.3);
        Object sl3(300, 8, 0.4);
        // Long Logs
        Object l1(799, 8.3, 0.4);
        Object l2(500, 125, 0.2);
        
        // Sets object's direction
        t1.moveRight(truck);
        t2.moveLeft(truck2);
        c1.moveRight(car);
        c2.moveLeft(car2);
        c3.moveLeft(car3);
        sl1.moveRight(shortLog);
        sl2.moveLeft(shortLog2);
        sl3.moveRight(shortLog3);
        l1.moveRight(longLog);
        l2.moveRight(longLog2);
        
        
        // *********************************************************************
        // The following rectangles are for collision detection
        // *********************************************************************
        // Frog
        sf::RectangleShape rect;
        
        // Trucks
        sf::RectangleShape rect2;
        sf::RectangleShape rect3;
        
        // Cars
        sf::RectangleShape rect4;
        sf::RectangleShape rect5;
        sf::RectangleShape rect6;
        
        // Short Logs
        sf::RectangleShape rect7;
        sf::RectangleShape rect8;
        sf::RectangleShape rect9;
        
        // Long Logs
        sf::RectangleShape rect10;
        sf::RectangleShape rect11;
        
        // River
        sf::RectangleShape rect12;
        
        // Lilypads
        sf::RectangleShape rect13;
        sf::RectangleShape rect14;
        sf::RectangleShape rect15;
        sf::RectangleShape rect16;
        sf::RectangleShape rect17;
        
        // *********************************************************************
        // Setting size of rectangles aka size(width, height)
        // *********************************************************************
        // Frog
        sf::Vector2f size(40, 40);
        
        // Truck
        sf::Vector2f size2(120, 70);
        sf::Vector2f size3(120, 70);
        sf::Vector2f size4(95, 70);
        
        // Cars
        sf::Vector2f size5(95, 70);
        sf::Vector2f size6(95, 70);
        
        // Short Logs
        sf::Vector2f size7(85, 35);
        sf::Vector2f size8(85, 35);
        sf::Vector2f size9(85, 35);
        
        // Long Log
        sf::Vector2f size10(135, 35);
        sf::Vector2f size11(135, 35);
        
        // River
        sf::Vector2f size12(800, 230);
        
        // Lilypads
        sf::Vector2f size13(60, 60);
        sf::Vector2f size14(60, 60);
        sf::Vector2f size15(60, 60);
        sf::Vector2f size16(60, 60);
        sf::Vector2f size17(60, 60);
        
        // *********************************************************************
        // Get pos of every object
        // *********************************************************************
        // Trucks
        sf::Vector2f objectPos = truck.getPosition();
        sf::Vector2f objectPos2 = truck2.getPosition();
        // Cars
        sf::Vector2f objectPos3 = car.getPosition();
        sf::Vector2f objectPos4 = car2.getPosition();
        sf::Vector2f objectPos5 = car3.getPosition();
        // Short Logs
        sf::Vector2f objectPos6 = shortLog.getPosition();
        sf::Vector2f objectPos7 = shortLog2.getPosition();
        sf::Vector2f objectPos8 = shortLog3.getPosition();
        // Long Logs
        sf::Vector2f objectPos9 = longLog.getPosition();
        sf::Vector2f objectPos10 = longLog2.getPosition();
        // Lilypad
        sf::Vector2f objectPos11 = lillypad.getPosition();
        sf::Vector2f objectPos12 = lillypad2.getPosition();
        sf::Vector2f objectPos13 = lillypad3.getPosition();
        sf::Vector2f objectPos14 = lillypad4.getPosition();
        sf::Vector2f objectPos15 = lillypad5.getPosition();
        
        // *********************************************************************
        // Sets boundary settings
        // *********************************************************************
        sf::Vector2f pos = frogger.getPosition();
        
        // Frog
        rect.setPosition(pos.x + 30 , pos.y +10);
        rect.setSize(size);
        rect.setFillColor(sf::Color::Transparent);
        rect.setOutlineColor(sf::Color::Red);
        rect.setOutlineThickness(5);
        
        // Trucks
        rect2.setPosition(objectPos.x + 40, objectPos.y + 20);
        rect2.setSize(size2);
        rect2.setFillColor(sf::Color::Transparent);
        rect2.setOutlineColor(sf::Color::Red);
        rect2.setOutlineThickness(5);
        
        rect3.setPosition(objectPos2.x + 40, objectPos2.y + 60);
        rect3.setSize(size3);
        rect3.setFillColor(sf::Color::Transparent);
        rect3.setOutlineColor(sf::Color::Red);
        rect3.setOutlineThickness(5);
        
        // Cars
        rect4.setPosition(objectPos3.x + 45, objectPos3.y + 70);
        rect4.setSize(size4);
        rect4.setFillColor(sf::Color::Transparent);
        rect4.setOutlineColor(sf::Color::Red);
        rect4.setOutlineThickness(5);
        
        rect5.setPosition(objectPos4.x + 50, objectPos4.y + 70);
        rect5.setSize(size5);
        rect5.setFillColor(sf::Color::Transparent);
        rect5.setOutlineColor(sf::Color::Red);
        rect5.setOutlineThickness(5);
        
        rect6.setPosition(objectPos5.x + 50, objectPos5.y + 70);
        rect6.setSize(size6);
        rect6.setFillColor(sf::Color::Transparent);
        rect6.setOutlineColor(sf::Color::Red);
        rect6.setOutlineThickness(5);
        
        // Short Logs
        rect7.setPosition(objectPos6.x + 30, objectPos6.y + 80);
        rect7.setSize(size7);
        rect7.setFillColor(sf::Color::Transparent);
        rect7.setOutlineColor(sf::Color::Red);
        rect7.setOutlineThickness(5);
        
        rect8.setPosition(objectPos7.x + 30, objectPos7.y + 80);
        rect8.setSize(size8);
        rect8.setFillColor(sf::Color::Transparent);
        rect8.setOutlineColor(sf::Color::Red);
        rect8.setOutlineThickness(5);
        
        rect9.setPosition(objectPos8.x + 30, objectPos8.y + 80);
        rect9.setSize(size9);
        rect9.setFillColor(sf::Color::Transparent);
        rect9.setOutlineColor(sf::Color::Red);
        rect9.setOutlineThickness(5);
        
        // Long Logs
        rect10.setPosition(objectPos9.x + 35, objectPos9.y + 70);
        rect10.setSize(size10);
        rect10.setFillColor(sf::Color::Transparent);
        rect10.setOutlineColor(sf::Color::Red);
        rect10.setOutlineThickness(5);
        
        rect11.setPosition(objectPos10.x + 35, objectPos10.y + 70);
        rect11.setSize(size11);
        rect11.setFillColor(sf::Color::Transparent);
        rect11.setOutlineColor(sf::Color::Red);
        rect11.setOutlineThickness(5);
        // River
        rect12.setPosition(0, 0);
        rect12.setSize(size12);
        rect12.setFillColor(sf::Color::Transparent);
        rect12.setOutlineColor(sf::Color::Red);
        rect12.setOutlineThickness(5);
        
        // Lilypads
        rect13.setPosition(objectPos11.x + 30, objectPos11.y+40);
        rect13.setSize(size13);
        rect13.setFillColor(sf::Color::Transparent);
        rect13.setOutlineColor(sf::Color::Red);
        rect13.setOutlineThickness(5);
        
        rect14.setPosition(objectPos12.x + 30 , objectPos12.y+40);
        rect14.setSize(size14);
        rect14.setFillColor(sf::Color::Transparent);
        rect14.setOutlineColor(sf::Color::Red);
        rect14.setOutlineThickness(5);
        
        rect15.setPosition(objectPos13.x + 30, objectPos13.y+40);
        rect15.setSize(size15);
        rect15.setFillColor(sf::Color::Transparent);
        rect15.setOutlineColor(sf::Color::Red);
        rect15.setOutlineThickness(5);
        
        rect16.setPosition(objectPos14.x + 30 , objectPos14.y+40);
        rect16.setSize(size16);
        rect16.setFillColor(sf::Color::Transparent);
        rect16.setOutlineColor(sf::Color::Red);
        rect16.setOutlineThickness(5);
        
        rect17.setPosition(objectPos15.x + 30 , objectPos15.y+40);
        rect17.setSize(size17);
        rect17.setFillColor(sf::Color::Transparent);
        rect17.setOutlineColor(sf::Color::Red);
        rect17.setOutlineThickness(5);
        
        // *********************************************************************
        // Frogger Hit Truck 1
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect2.getGlobalBounds()))
            
        {
            
            froggerTheme.pause();
            trucked.play();
            
            lives = mainPlayer.getNumLives();
            mainPlayer.setNumLives(lives - 1);
            mainPlayer.setIsHit(true);
            rectSource.width -= 38.3;
            life.setTextureRect(rectSource);
         
            froggerTheme.play();
            //death.setPosition(-100,-100);
        }
        // *********************************************************************
        // Frogger Hit Truck 2
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect3.getGlobalBounds()))
        {
            froggerTheme.pause();
            trucked.play();
            
            lives = mainPlayer.getNumLives();
            mainPlayer.setNumLives(lives - 1);
            mainPlayer.setIsHit(true);
            rectSource.width -= 38.3;
            life.setTextureRect(rectSource);
            
            sf::Vector2f pos = frogger.getPosition();
            death.setPosition(pos);
            
            froggerTheme.play();
            death.setPosition(-100,-100);
            
        }
        // *********************************************************************
        // Frogger Hit Car 1
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect4.getGlobalBounds()))
        {
            froggerTheme.pause();
            trucked.play();
            
            lives = mainPlayer.getNumLives();
            mainPlayer.setNumLives(lives - 1);
            mainPlayer.setIsHit(true);
            rectSource.width -= 38.3;
            life.setTextureRect(rectSource);
            
            sf::Vector2f pos = frogger.getPosition();
            death.setPosition(pos);
            
            froggerTheme.play();
            death.setPosition(-100,-100);
            
        }
        // *********************************************************************
        // Frogger Hit Car 2
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect5.getGlobalBounds()))
        {
            froggerTheme.pause();
            trucked.play();
            
            lives = mainPlayer.getNumLives();
            mainPlayer.setNumLives(lives - 1);
            mainPlayer.setIsHit(true);
            rectSource.width -= 38.3;
            life.setTextureRect(rectSource);
            
            sf::Vector2f pos = frogger.getPosition();
            death.setPosition(pos);
            
            froggerTheme.play();
            death.setPosition(-100,-100);
            
        }
        // *********************************************************************
        // Frogger Hit Car 3
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect6.getGlobalBounds()))
        {
            froggerTheme.pause();
            trucked.play();
            
            lives = mainPlayer.getNumLives();
            mainPlayer.setNumLives(lives - 1);
            mainPlayer.setIsHit(true);
            rectSource.width -= 38.3;
            life.setTextureRect(rectSource);
            
            sf::Vector2f pos = frogger.getPosition();
            death.setPosition(pos);
            
            froggerTheme.play();
            death.setPosition(-100,-100);
            
        }
        
        // *********************************************************************
        // Below this line will be log collision checking
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect7.getGlobalBounds()))
        {
            frogger.setPosition(objectPos6.x + 45 + sum2 , objectPos6.y + 80 + sum);
            isOnLog = true;
        }
        else
        {
            isOnLog = false;
            sum = 0;
            sum2 = 0;
        }
        
        if (rect.getGlobalBounds().intersects(rect8.getGlobalBounds()))
        {
            
            frogger.setPosition(objectPos7.x + 45 + sum4, objectPos7.y + 80 + sum3);
            isOnLog2 = true;
        }
        else
        {
            isOnLog2 = false;
            sum3 = 0;
            sum4 = 0;
        }
        if (rect.getGlobalBounds().intersects(rect9.getGlobalBounds()))
        {
            frogger.setPosition(objectPos8.x + 45+sum6, objectPos8.y + 80+sum5);
            isOnLog3 = true;
        }
        else
        {
            isOnLog3 = false;
            sum5 = 0;
            sum6 = 0;
            
        }
        if (rect.getGlobalBounds().intersects(rect10.getGlobalBounds()))
        {
            frogger.setPosition(objectPos9.x + 45 + sum8, objectPos9.y + 70+ sum7);
            isOnLog4 = true;
            
        }
        else
        {
            isOnLog4 = false;
            sum7 = 0;
            sum8 = 0;
        }
        if (rect.getGlobalBounds().intersects(rect11.getGlobalBounds()))
        {
            frogger.setPosition(objectPos10.x + 45+ sum10, objectPos10.y + 70+sum9);
            isOnLog5 = true;
        }
        else
        {
            isOnLog5 = false;
            sum9 = 0;
            sum10 = 0;
        }
        
        // *********************************************************************
        // Below this line will be lily collision checking
        // *********************************************************************
        if (rect.getGlobalBounds().intersects(rect13.getGlobalBounds()))
        {
            isOnLily = true;
            if (frogOnLily1 == false)
            {
                score += 50;
            }
            frogOnLily1 = true;
            sf::Vector2f lilyPos = rect13.getPosition();
            occupied1.setPosition(lilyPos);
            
        }
        if (rect.getGlobalBounds().intersects(rect14.getGlobalBounds()))
        {
            isOnLily = true;
            if (frogOnLily2 == false)
            {
                score += 50;
            }
            frogOnLily2 = true;
            sf::Vector2f lilyPos = rect14.getPosition();
            occupied2.setPosition(lilyPos);
        }
        if (rect.getGlobalBounds().intersects(rect15.getGlobalBounds()))
        {
            isOnLily = true;
            if (frogOnLily3 == false)
            {
                score += 50;
            }
            frogOnLily3 = true;
            sf::Vector2f lilyPos = rect15.getPosition();
            occupied3.setPosition(lilyPos);
            
        }
        if (rect.getGlobalBounds().intersects(rect16.getGlobalBounds()))
        {
            isOnLily = true;
            if (frogOnLily4 == false)
            {
                score += 50;
            }
            frogOnLily4 = true;
            sf::Vector2f lilyPos = rect16.getPosition();
            occupied4.setPosition(lilyPos);
        }
        if (rect.getGlobalBounds().intersects(rect17.getGlobalBounds()))
        {
            isOnLily = true;
            if (frogOnLily5 == false)
            {
                score += 50;
            }
            frogOnLily5 = true;
            sf::Vector2f lilyPos = rect17.getPosition();
            occupied5.setPosition(lilyPos);
        }
        
        // *********************************************************************
        // Checks if frogger is on log AND goes outside screen boundaries
        //  if so frogger dies
        // *********************************************************************
        sf::Vector2f location = frogger.getPosition();
        // Checks if frogger went out of bounds
        if (rect.getGlobalBounds().intersects(rect12.getGlobalBounds()))
        {
            if ((isOnLog || isOnLog2 || isOnLog3 || isOnLog4 || isOnLog5) && (location.x >= 740 || location.x < -40))
            {
                mainPlayer.setIsHit(true);
                lives = mainPlayer.getNumLives();
                mainPlayer.setNumLives(lives - 1);
                rectSource.width -= 38.3;
                life.setTextureRect(rectSource);
                
            }
        }
        // Checks if frogger is on the logs not the water
        if (rect.getGlobalBounds().intersects(rect12.getGlobalBounds()))
        {
            if (isOnLog || isOnLog2 || isOnLog3 || isOnLog4 || isOnLog5)
            {
                //this frogger is on the logs not the water
            }
            else
            {
                froggerTheme.pause();
                dunked.play();
                froggerTheme.play();
                mainPlayer.setIsHit(true);
                lives = mainPlayer.getNumLives();
                mainPlayer.setNumLives(lives - 1);
                rectSource.width -= 38.3;
                life.setTextureRect(rectSource);
            }
            
        }
        // Checks if the frog has landed on a lilypad
        if (isOnLily || isOnLily2 || isOnLily3 || isOnLily4 || isOnLily5)
        {
            // the frog has landed on the lily pad
            froggerLanded = true;
        }
        // *********************************************************************
        // Checks if the frog has landed on all 5 lilypads if so you win
        // *********************************************************************
        if (frogOnLily1 && frogOnLily2 && frogOnLily3 && frogOnLily4 && frogOnLily5)
        {
            score += 10000;
            
            frogOnLily1 = false;
            frogOnLily2 = false;
            frogOnLily3 = false;
            frogOnLily4 = false;
            frogOnLily5 = false;
            
            mainPlayer.setNumLives(3);
            rectSource.width = 115;
            life.setTextureRect(rectSource);
            occupied1.setPosition(-100, -100);
            occupied2.setPosition(-100, -100);
            occupied3.setPosition(-100, -100);
            occupied4.setPosition(-100, -100);
            occupied5.setPosition(-100, -100);
            froggerTheme.pause();
            clock.restart();
            timeRect.width = 143;
            timer.setTextureRect(timeRect);
            frogger.setPosition(320, 605);
            
            return 2;
        }
        while (App.pollEvent(Event))
        {
            // Window closed
            if (Event.type == sf::Event::Closed)
            {
                return (-1);
            }
            // *********************************************************************
            // LEFT
            // *********************************************************************
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
            {
                
                if (isOnLog)
                {
                    sum2 = (sum2 + (20 * -1));
                }
                if (isOnLog2)
                {
                    sum4 = (sum4 + (20 * -1));
                }
                if (isOnLog3)
                {
                    sum6 = (sum6 + (20 * -1));
                }
                if (isOnLog4)
                {
                    sum8 = (sum8 + (20 * -1));
                }
                if (isOnLog5)
                {
                    sum10 = (sum10 + (20 * -1));
                }
                
                
                sf::Vector2f pos = frogger.getPosition();
                
                
                if (pos.x < 0)
                {
                    frogger.move(0, 0);
                }
                else
                {
                    if (rectSourceSprite.left != 216)
                    {
                        rectSourceSprite.left = 216;
                        rectSourceSprite.width = 55;
                        frogger.setTextureRect(rectSourceSprite);
                    }
                    score += 10;
                    froggerTheme.setVolume(0);
                    hop.play();
                    frogger.move(-40, 0);
                    froggerTheme.setVolume(50);
                    
                }
            }
            // *********************************************************************
            // RIGHT
            // *********************************************************************
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
            {
                if (isOnLog)
                {
                    sum2 = (sum2 + (20));
                }
                if (isOnLog2)
                {
                    sum4 = (sum4 + (20));
                }
                if (isOnLog3)
                {
                    sum6 = (sum6 + (20));
                }
                if (isOnLog4)
                {
                    sum8 = (sum8 + (20));
                }
                if (isOnLog5)
                {
                    sum10 = (sum10 + (20));
                }
                
                sf::Vector2f pos = frogger.getPosition();
                
                if (pos.x >= 640)
                {
                    frogger.move(0, 0);
                }
                else
                {
                    if (rectSourceSprite.left != 89)
                    {
                        rectSourceSprite.left = 89;
                        rectSourceSprite.width = 60;
                        frogger.setTextureRect(rectSourceSprite);
                    }
                    score += 10;
                    froggerTheme.setVolume(0);
                    hop.play();
                    frogger.move(40, 0);
                    froggerTheme.setVolume(50);
                }
            }
            // *********************************************************************
            // UP
            // *********************************************************************
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
            {
                
                
                if (isOnLog)
                {
                    sum = (sum + (20 * -1));
                }
                
                if (isOnLog2)
                {
                    sum3 = (sum3 + (20 * -1));
                }
                if (isOnLog3)
                {
                    sum5 = (sum5 + (20 * -1));
                }
                if (isOnLog4)
                {
                    sum7 = (sum7 + (20 * -1));
                }
                if (isOnLog5)
                {
                    sum9 = (sum9 + (20 * -1));
                }
                
                
                if (pos.y <= -35)
                {
                    frogger.move(0, 0);
                }
                else
                {
                    if (rectSourceSprite.left != 0)
                    {
                        rectSourceSprite.left = 0;
                        rectSourceSprite.width = 89;
                        frogger.setTextureRect(rectSourceSprite);
                    }
                    score += 10;
                    froggerTheme.setVolume(0);
                    hop.play();
                    frogger.move(0, -40);
                    froggerTheme.setVolume(50);
                }
            }
            // *********************************************************************
            // DOWN
            // *********************************************************************
            if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
            {
                
                
                if (isOnLog)
                {
                    sum = (sum + 20);
                }
                
                if (isOnLog2)
                {
                    sum3 = (sum3 + 20);
                }
                if (isOnLog3)
                {
                    sum5 = (sum5 + 20);
                }
                
                if (isOnLog4)
                {
                    sum7 = (sum7 + 20);
                }
                if (isOnLog5)
                {
                    sum9 = (sum9 + 20);
                }
                sf::Vector2f pos = frogger.getPosition();
                if (pos.y >= 650)
                {
                    frogger.move(0, 0);
                }
                else
                {
                    if (rectSourceSprite.left != 149)
                    {
                        rectSourceSprite.left = 149;
                        rectSourceSprite.width = 67;
                        frogger.setTextureRect(rectSourceSprite);
                    }
                    score += 10;
                    froggerTheme.setVolume(0);
                    hop.play();
                    frogger.move(0, 40);
                    froggerTheme.setVolume(50);
                }
            }
        }
        
        // *********************************************************************
        // Checks if player has been hit
        // *********************************************************************
        if (mainPlayer.getIsHit() == true)
        {
            cout << " Number of lives" << mainPlayer.getNumLives() << endl;
            mainPlayer.setIsHit(false);
            rectSourceSprite.left = 0;
            rectSourceSprite.width = 89;
            frogger.setTextureRect(rectSourceSprite);
            frogger.setPosition(320, 605);
        }
        // *********************************************************************
        // Checks if player landed on lily
        // *********************************************************************
        if (froggerLanded == true)
        {
            froggerLanded = false;
            rectSourceSprite.left = 0;
            rectSourceSprite.width = 89;
            frogger.setTextureRect(rectSourceSprite);
            frogger.setPosition(320, 605);
            isOnLily = false;
            isOnLily2 = false;
            isOnLily3 = false;
            isOnLily4 = false;
            isOnLily5 = false;
        }
        // *********************************************************************
        // Checks if player has run out of lives
        // *********************************************************************
        if (mainPlayer.getNumLives() < 1)
        {
            frogOnLily1 = false;
            frogOnLily2 = false;
            frogOnLily3 = false;
            frogOnLily4 = false;
            frogOnLily5 = false;
            mainPlayer.setNumLives(3);
            rectSource.width = 115;
            life.setTextureRect(rectSource);
            occupied1.setPosition(-100, -100);
            occupied2.setPosition(-100, -100);
            occupied3.setPosition(-100, -100);
            occupied4.setPosition(-100, -100);
            occupied5.setPosition(-100, -100);
            froggerTheme.pause();
            clock.restart();
            timeRect.width = 143;
            timer.setTextureRect(timeRect);
            frogger.setPosition(320, 605);
            
            return 2;
            
        }
        
        App.clear(sf::Color(0, 0, 0, 0));
        //Drawing
        App.draw(background);
        App.draw(car2);
        App.draw(car3);
        App.draw(truck2);
        App.draw(truck);
        App.draw(car);
        App.draw(longLog);
        App.draw(longLog2);
        App.draw(shortLog);
        App.draw(shortLog2);
        App.draw(shortLog3);
        App.draw(lillypad);
        App.draw(lillypad2);
        App.draw(lillypad3);
        App.draw(lillypad4);
        App.draw(lillypad5);
        App.draw(life);
        App.draw(timer);
        App.draw(frogger);
        App.draw(occupied1);
        App.draw(occupied2);
        App.draw(occupied3);
        App.draw(occupied4);
        App.draw(occupied5);

        // *********************************************************************
        // The following are for testing purposes only
        // Draws the boundary box
        // *********************************************************************
        App.draw(rect);
        App.draw(rect2);
        App.draw(rect3);
        App.draw(rect4);
        App.draw(rect5);
        App.draw(rect6);
        App.draw(rect7);
        App.draw(rect8);
        App.draw(rect9);
        App.draw(rect10);
        App.draw(rect11);
        App.draw(rect12);
        App.draw(rect13);
        App.draw(rect14);
        App.draw(rect15);
        App.draw(rect16);
        App.draw(rect17);
        
        App.display();
    }
    
    //Never reaching this point normally, but just in case, exit the application
    return -1;
}