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


C++ Enemy::endTurn方法代码示例

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


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

示例1: main

int main(int argc, char* argv[])
{
    int seed = init_rand();
    //int seed = init_rand(1314485160);
    std::cout << "seed:" << seed << std::endl;

    initScreen();
    displayTitleScreen();

    int world_width = worldScreenDims[WIDTH];
    int world_height = worldScreenDims[HEIGHT];
    int world_depth = 5;

    world = new World(world_width, world_height, world_depth);
    setWorld(world);//interface.h, just to keep a pointer to the world so It doesn't have to get passed with every message, prompt, etc. probably a better way to do this but i cba
    player = world->generatePlayer();
    enemies = world->generateEnemies(4,8);
    world->generateItems(25,50);

    std::stringstream intro_stream;
    intro_stream << "You are " << player->getName() << ", an Adventurer in search of the Icon of Weedaula.";
    message(intro_stream.str());
    message("Bring the Icon back to the surface to win the game!");
    message("Press '?' for help");

    while (!isGameOver())
    {
        world->incrementTimeStep();
        player->FOV(player->getMapLevel());
        displayGameScreen();
        updateScreen();

        player->startTurn();
        while (!player->isTurnFinished() && player->isTurn() && !isGameOver())
        {
            handleKeyPress();
        }
        player->endTurn();

        enemies = world->getEnemyList();
        for (unsigned int i = 0; i < enemies.size(); i++)
        {
            Enemy *en = enemies[i];
            en->FOV(en->getMapLevel());
            en->startTurn();
            if (en->isTurn() && withinRange(en->getMapLevel(), player->getMapLevel(), player->getMapLevel()))
            {
                en->takeTurn();
            }
            en->endTurn();
        }
    }

    if (isGameOver())
    {
        if (!player->isAlive())
        {
            displayGameOverScreen("You have been struck down");
        }
    }
}
开发者ID:javonharper,项目名称:Tomb-The-Roguelike,代码行数:61,代码来源:main.cpp


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