BeatTheStreet/src/player.cpp
//Constructor for initializing the object.
Constructor for initializing the object.
Constructor for initializing the object .
Player::Player()
{
	sf::Vector2f size(50.f, 75.f);											
	if (!pTextureRight.loadFromFile(".\\Assets\\graphics\\frogright.png")) EXIT_FAILURE;
	if (!pTextureLeft.loadFromFile(".\\Assets\\graphics\\frogleft.png")) EXIT_FAILURE;
	if (!pTextureBack.loadFromFile(".\\Assets\\graphics\\frogback.png")) EXIT_FAILURE;
	if (!pTextureFront.loadFromFile(".\\Assets\\graphics\\frogfront.png")) EXIT_FAILURE;
	sPlayer.setTexture(pTextureBack);
	sPlayer.setOrigin(25, 50);
	sPlayer.setPosition(400, 805);
	iPlayerLives = 3;
	if (!sbSplashBuffer.loadFromFile(".\\Assets\\audio\\splash.ogg"))EXIT_FAILURE;
	if (!sbCollideBuffer.loadFromFile(".\\Assets\\audio\\playerhit.ogg"))EXIT_FAILURE;
	sSplashSound.setBuffer(sbSplashBuffer);
	sCollideSound.setBuffer(sbCollideBuffer);
}
Player :: Player ( ) { sf :: Vector2f size ( 50.f , 75.f ) ; if ( ! pTextureRight . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; if ( ! pTextureLeft . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; if ( ! pTextureBack . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; if ( ! pTextureFront . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; sPlayer . setTexture ( pTextureBack ) ; sPlayer . setOrigin ( 25 , 50 ) ; sPlayer . setPosition ( 400 , 805 ) ; iPlayerLives = 3 ; if ( ! sbSplashBuffer . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; if ( ! sbCollideBuffer . loadFromFile ( " \\ \\ \\ " ) ) EXIT_FAILURE ; sSplashSound . setBuffer ( sbSplashBuffer ) ; sCollideSound . setBuffer ( sbCollideBuffer ) ; }
Constructor for initializing the object.
Constructor for initializing the object .
//Size of sprite used when setting scale //Load textures from file. //Set the texture of the sprite so that the character is initially facing away. //Set origin and position //Player starts with 3 lives //Load files into sound buffers //Set sounds to sound buffers