当前位置: 首页>>代码示例>>C++>>正文


C++ TimeManager::getAccumulator方法代码示例

本文整理汇总了C++中TimeManager::getAccumulator方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeManager::getAccumulator方法的具体用法?C++ TimeManager::getAccumulator怎么用?C++ TimeManager::getAccumulator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeManager的用法示例。


在下文中一共展示了TimeManager::getAccumulator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Space Invaders");
    //STARTING SETTINGS

    AudioManager audioManager;
    BulletManager bulletManager;
    EnemyManager enemyManager;
    Randomizer random;
    TimeManager time;
    Menu mainMenu;
    Interface mainInterface;
    Player player(400, 500);
    Player *playerWsk = &player;

    //CONTROL VARIABLES
    bool menu = true;
    bool init = false;
    bool menuMusic = false;
    bool stageTwo = false;


    mainMenu.loadData();

    while (window.isOpen())
    {
        if(menu == false)
        {

            if(init == false)
            {
                audioManager.stopMenu();
                menuMusic = false;

                player.setHealth(3);


                //CREATING ENEMIES and INITILIAZING
                enemyManager.addEnemies(); //2 ROWS


                random.initialize();
                audioManager.playMusic();
                init = true;
            }
        if((stageTwo == false) && (mainInterface.getScore() >= 280))
        {
            enemyManager.addEnemiesMedium();
            stageTwo = true;

        }
        if((mainInterface.getScore() >= 560))
        {
            audioManager.stopMusic();
            init = false;
            menu = true;
        }

        time.updateShoot();
        time.updateRandomShoot();
        // REFRESHING WINDOW
        // ALL PHYSICS HERE

        while(time.getAccumulator() > time.getUps())
        {
            time.updateAccumulator();
            player.keyboardControl(time.getUps(), bulletManager, time.getShootTimer(), time, audioManager);
            enemyManager.controlEnemies(random, bulletManager, time);
            bulletManager.controlBullets(time.getUps());


            //COLLISIONS
            bulletManager.checkPlayerCollisions(playerWsk);
            enemyManager.updateDead(bulletManager);
            player.gameOver(audioManager, menu, init);

        }


        //SIMPLE EVENTS
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        mainInterface.checkRecords(mainMenu);

        //DRAWING
        window.clear();
        mainInterface.drawText(window, player.getHealth());
        enemyManager.drawEnemies(window);
        window.draw(player.getSprite());
        bulletManager.drawBullets(window);
        window.display();

         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
            {
                window.close();
            }
//.........这里部分代码省略.........
开发者ID:Th3NiKo,项目名称:Projects,代码行数:101,代码来源:main.cpp


注:本文中的TimeManager::getAccumulator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。