예제 #1
0
void PlayerHUD::renderSpells(sf::RenderTarget& targ, float scaleX, float scaleY) const {
	glPushMatrix();
	const int id = mPlayer->mGamepad->getId();
	Spell** spells = mPlayer->mSpellArray;
	const sf::Vector2f& spellSize = spells[0]->getThumbnail()->GetSize();
	const int spellHalfW = spellSize.x / 2;
	const int spellHalfH = spellSize.y / 2;

	if(id%2) {
		glTranslatef(targ.GetWidth() - spellSize.x, 0, 0);
	}

	if(id>=2) {
		glTranslatef(0, targ.GetHeight() - spellSize.y, 0);
	}
	//LT
	renderSingleSpell(targ, spells[0], 5*scaleX, 110*scaleY);

	//LB
	renderSingleSpell(targ, spells[1], 53*scaleX, 108*scaleY);

	//RB
	renderSingleSpell(targ, spells[3], 96*scaleX, 91*scaleY);

	//RT
	renderSingleSpell(targ, spells[2], 115*scaleX, 45*scaleY);
	glPopMatrix();
}
예제 #2
0
void MainMenuState::render(sf::RenderTarget& window) const
{
	
	//render background/sprite 
	window.Draw(*mSprite);
	// position menu background
	mSpriteMenu->SetPosition(0.74*window.GetWidth()-0.5*mSpriteMenu->GetSize().x, 0.5*window.GetHeight()-0.5*mSpriteMenu->GetSize().y);
	window.Draw(*mSpriteMenu);
	
	// put the positions and render buttons 
	for( int i=0; i< mAmountOfButtons; i++)
	{
		
		mButtons[i]->setPosition(0.75*window.GetWidth()-0.25*mButtons[i]->getSizeWidth()+58, 0.5*window.GetHeight()-0.25*mAmountOfButtons*mButtons[i]->getSizeHeight()+i*mButtons[i]->getSizeHeight()-90+i*11);
		if(i==4)
		{
			mButtons[4]->moveButton(sf::Vector2f(-12.0f, 67.5f));
		}
		mButtons[i]->render(window);	

	}

	
}
예제 #3
0
void GridPoint::render(sf::RenderTarget &tgt) {
// We don't want the circle to scale with the image, so we have to break out of
// the current View and compute the position manually.

	const sf::View &view = tgt.GetView();
	sf::FloatRect rect = view.GetRect();

	float xtrans = rect.Left + (x * tgt.GetWidth() / rect.GetWidth());
	float ytrans = rect.Top + (y * tgt.GetHeight() / rect.GetHeight());

	tgt.SetView( tgt.GetDefaultView() );
	
	sf::Shape circle = sf::Shape::Circle(xtrans, ytrans, 5,
	                                     sf::Color(0, 0, 0, 0),
	                                     1, sf::Color(255, 0, 0));
	tgt.Draw(circle);

	tgt.SetView(view);
}
예제 #4
0
void PlayerHUD::renderFrame(sf::RenderTarget& targ) const {
	const int id = mPlayer->mGamepad->getId();
	const sf::Vector2f& size = this->mSpriteBox->GetSize();

	glPushMatrix();

	//Check if the player should be aligned to the right side of the screen.
	if(id%2) {
		glTranslatef(targ.GetWidth() - size.x, 0, 0);
	}

	//Check if this frame is in the bottom of the screen
	if(id >= 2) {
		glTranslatef(0, targ.GetHeight() - size.y, 0);
	}

	targ.Draw(*mSpriteBox);

	glPopMatrix();
}