本文整理汇总了C++中Hero::get_health方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::get_health方法的具体用法?C++ Hero::get_health怎么用?C++ Hero::get_health使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::get_health方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
srand(time(NULL));
Background::load_background();
Sound::load_sounds();
Sprites::load_sprites();
Font::load_font();
window.setFramerateLimit(30);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && shot_counter==0){
break;
}
window.draw(Background::before_game_start_sprite);
window.display();
}
Hero hero;
Enemys enemys;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
shot_counter++;
shot_counter%=10;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && shot_counter==0){
hero.fire();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
hero.move_left();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
hero.move_right();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
hero.move_up();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
hero.move_down();
}
Sound::play_background_music();
Background::show(window);
hero.turn(window);
enemys.turn(window);
window.display();
if (hero.get_health()<=0) break;
}
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && shot_counter==0){
break;
}
Sound::game_music.stop();
window.draw(Background::gameover_sprite);
window.display();
}
return 0;
}