本文整理汇总了C++中HUD::changeScore方法的典型用法代码示例。如果您正苦于以下问题:C++ HUD::changeScore方法的具体用法?C++ HUD::changeScore怎么用?C++ HUD::changeScore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HUD
的用法示例。
在下文中一共展示了HUD::changeScore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solo
//.........这里部分代码省略.........
if(clock.getElapsedTime() > sf::seconds(1.f))
{
std::stringstream ss;//create a stringstream
ss << frames;//add number to the stream
p_window->setTitle("SFMl window FPS="+ss.str());
clock.restart();
frames = 0;
}
frames += 1;
p_window->clear();
backgroung.Draw(p_window);
for(std::vector<Bonus*>::size_type u = 0 ; u < bonus_tab.size() ; u++)
{
bonus_tab.at(u)->Draw(p_window);
}
for(std::vector<missile*>::size_type i = 0 ; i < missile_tab.size() ; i++)//parcour de tous les missiles
{
sf::Vector2f missilPos = missile_tab[i]->getPosition();
missile_tab[i]->Draw(p_window);//on le dessine
if(missilPos.y < 0 or missilPos.y > p_window->getSize().y or missilPos.x < 0 or missilPos.x > p_window->getSize().x)//si or de la fenetre
missile_tab.erase(missile_tab.begin()+i);//on le suprime
else//sinon on regarde les colisions
{
for(std::vector<vaisseau*>::size_type j = 0 ; j < entity_tab.size() ; j++)
{
sf::FloatRect entityBound = entity_tab[j]->getGlobalBound();//recupération des donnée du vaisseau
if(entityBound.left < -50 or entityBound.top < -50 or entityBound.top > p_window->getSize().y+50 or entityBound.left > p_window->getSize().x+50)//on en profite pour regarder si il est bien dans la fenetre
{
entity_tab.erase(entity_tab.begin()+j);
}
else if(
!(missilPos.y < entityBound.top or missilPos.y > entityBound.top+entityBound.height or
missilPos.x < entityBound.left or missilPos.x > entityBound.left+entityBound.width))//le missile touche-il l'entité?
{
missile_tab.erase(missile_tab.begin()+i);//supression du missile
entity_tab[j]->onHit(1.f);//on inflige 1 de degat a l'entité
if(entity_tab[j]->isAlive()==false)
{
spawnBonus=spawnBonus+0.8;
if(spawnBonus>2 && spawnBonus!= 2.2)
{
bonus_tab.push_back(new Bonus(entity_tab[j]->getPosition(),sf::Color(200, 0 ,0),sf::Color(250, 0 ,0), 0.5));
spawnBonus = spawnBonus-2;
}
else if(spawnBonus==2)
{
bonus_tab.push_back(new Bonus(entity_tab[j]->getPosition(),sf::Color(0, 200 ,0), sf::Color(0, 250 ,0), 0.5));
spawnBonus = spawnBonus-2;
}
}
}
}
}
}
sf::FloatRect playerBound = entity_tab[0]->getGlobalBound();
for(std::vector<Bonus*>::size_type a = 0 ; a < bonus_tab.size() ; a++)
{
sf::FloatRect bonusBound = bonus_tab[a]->getGlobalBound();
if(bonusBound.left+bonusBound.width<0 or bonusBound.left>(float) p_window->getSize().x or bonusBound.top+bonusBound.height<0 or bonusBound.top > (float) p_window->getSize().y)
{
bonus_tab.erase(bonus_tab.begin()+a);
}
else if(!(bonusBound.left<playerBound.left or bonusBound.left>playerBound.left+playerBound.width or bonusBound.top<playerBound.top or bonusBound.top>playerBound.top+playerBound.height)
or !(bonusBound.left+bonusBound.width<playerBound.left or bonusBound.left+bonusBound.width>playerBound.left+playerBound.width or bonusBound.top<playerBound.top or bonusBound.top>playerBound.top+playerBound.height)
or !(bonusBound.left<playerBound.left or bonusBound.left>playerBound.left+playerBound.width or bonusBound.top+bonusBound.height<playerBound.top or bonusBound.top+bonusBound.height>playerBound.top+playerBound.height)
or !(bonusBound.left+bonusBound.width<playerBound.left or bonusBound.left+bonusBound.width>playerBound.left+playerBound.width or bonusBound.top+bonusBound.height<playerBound.top or bonusBound.top+bonusBound.height>playerBound.top+playerBound.height))
{
scores.changeScore(bonus_tab[a]->getFillColor(), bonus_tab[a]->getOutlineColor(), bonus_tab[a]->bonusVal());
bonus_tab.erase(bonus_tab.begin()+a);
}
}
for(std::vector<vaisseau*>::size_type u = 0 ; u < entity_tab.size() ; u++)
{
entity_tab.at(u)->Draw(p_window);
}
scores.Draw(p_window);
p_window->display();
}
return 0;
}