예제 #1
0
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");
        }
    }
}