本文整理汇总了C++中screen::getRun方法的典型用法代码示例。如果您正苦于以下问题:C++ screen::getRun方法的具体用法?C++ screen::getRun怎么用?C++ screen::getRun使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screen
的用法示例。
在下文中一共展示了screen::getRun方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ( int argc, char** argv)
{
sf::RenderWindow window(sf::VideoMode(wW, wH), "MyDynablaster", sf::Style::Titlebar);
sf::Clock clock;
//==================================================================================================== Textures for objects
sf::Texture texMainHero;
texMainHero.loadFromFile("main_hero.png");
sf::Sprite sprMainHero;
sprMainHero.setTexture(texMainHero);
sf::Texture texBrick;
texBrick.loadFromFile("brick.png");
sf::Sprite sprBrick;
sprBrick.setTexture(texBrick);
sf::Texture texEnemy;
texEnemy.loadFromFile("enemy.png");
sf::Sprite sprEnemy;
sprEnemy.setTexture(texEnemy);
sf::Texture texBomb;
texBomb.loadFromFile("bomb.png");
sf::Sprite sprBomb;
sprBomb.setTexture(texBomb);
sf::Texture texPortal;
texPortal.loadFromFile("portal.png");
sf::Sprite sprPortal;
sprPortal.setTexture(texPortal);
sf::Texture texFire;
texFire.loadFromFile("fire.png");
sf::Sprite sprFire;
sprFire.setTexture(texFire);
sf::Font font;
if (!font.loadFromFile("font.ttf"))
{
return 3;
}
//-----------------------------------------------------------------------------------------------Boolean variables
bool lvl_is_completed = false;
bool in_menu = true;
bool gamer_lose = false;
// -----------------------------------------------------------------------------------------------Game
while (window.isOpen())
{
sf::Event event;
while ( in_menu)
{
window.clear(sf::Color::White);
sf::Text txt1, txt2;
const int txt1_x = 100, txt1_y=100;
txt1.setFont(font);
txt1.setString("Start game");
txt1.setColor(sf::Color::Black);
txt1.setPosition(txt1_x, txt1_y);
txt1.setCharacterSize(72);
window.draw(txt1);
const int txt2_x = 100, txt2_y=180;
txt2.setFont(font);
txt2.setString("Exit");
txt2.setColor(sf::Color::Black);
txt2.setPosition(txt2_x,txt2_y);
txt2.setCharacterSize(72);
window.draw(txt2);
window.display();
while ( window.pollEvent(event))
{
eventsInMenu( event, window, in_menu, txt1_x, txt1_y, txt2_x, txt2_y);
}
}
while ( window.pollEvent(event) )
{
if(scrn.getRun())
{
eventsInGame(event, window);
}
else
{
if(gamer_lose)
{
eventsAfterLosing (event, window, in_menu);
}
else
{
eventsAfterWin (event, window, in_menu, 100, 150, 100, 250);
}
//.........这里部分代码省略.........