Exemplo n.º 1
0
int battle(int monsterspeed, int monsterattack, string enemyType)
{
    int battlerun = 1;
    //Battle Loop
    while (battlerun == 1)
    {
        madechoice = 0;
        while (madechoice == 0)
        {
            clearScreen();
	    //Main Battle Menu
            cout << menuBar;
            cout << "       " << enemyType << "Battle \n\n";
            displayEnemy(enemyType);
//	    healthMessage();
//	    magicMessage();
	    drunkMessage();
            cout << "Your attack is " << playersAttack << "\n";
            cout << "Your speed  is " << playersSpeed << "\n";
            cout << "Your AC is " << playersAC << "\n";
            cout << "           (1) Attack\n";
            cout << "           (2) Item Menu\n";
            cout << "           (3) Run Away\n\n";
            cout << menuBar;
            cin >> playerchoice;
            if (playerchoice == 2)
            {
                itemMenu();
            }
            else if (playerchoice == 3)
            {
                return 0;
            }
            else
            {
                madechoice = 1;
            }
        }
	//Checks if player's alive after player attack function
        bool stillAlive = playerAttack(playersSpeed, playersAttack, enemyType);
        if (stillAlive == false)
        {
            battlerun = 0;
            return 0;
        }
	//Checks if monster's alive after monster attack function
        stillAlive = monsterAttack(monsterspeed, monsterattack, enemyType);
        if (stillAlive == false)
        {
            battlerun = 0;
            return 1;
        }
    }
}
Exemplo n.º 2
0
void Picking::versusAnim()
{
    if (m_battle == nullptr)
    {
        m_battle = new Battle(m_instance);
    }

    //display player
    displayIcon();
    //display enemy card
    displayEnemy();

    Generic::shake(m_instance);

    //enemy animation
    //auto hide = Hide::create();
    //auto jump = MoveBy::create(0.3, Vec2(0, 30));
    //auto back = MoveBy::create(0.3, Vec2(0, -30));
    //auto cFunc = CallFunc::create([this](){this->enemyFlipAnim(); });
    auto smallenEnemy = ScaleBy::create(0.5, 0.8);
    auto delayEnemy = DelayTime::create(1);
    auto moveEnemy = MoveBy::create(1, Vec2(0, 850));
    auto hideEnem = Hide::create();
    m_enemyCard->runAction(Sequence::create(smallenEnemy, delayEnemy, moveEnemy, hideEnem, NULL));

    //player animation
    auto smallenPlayer = ScaleBy::create(0.5, 0.8);
    auto delayPlayer = DelayTime::create(1);
    auto movePlayer = MoveBy::create(1, Vec2(0, -850));
    auto hidePlayer = Hide::create();
    auto callback = CallFunc::create([this]() {
        this->setCards();
    });
    auto sequence = Sequence::create(smallenPlayer, delayPlayer, movePlayer, hidePlayer, callback, NULL);
    m_iconSprite->runAction(sequence);
}
Exemplo n.º 3
0
int		main(void)
{
    int		key;
    int		i;
    int		iframe;
    Bullet	*bul = new Bullet[200];
    Bullet	*bulEn = new Bullet[100];
    Ship	*ship = new Ship[50];
    Ast		*ast = new Ast[50];
    Star	*stars = new Star[100];
    Player	*player = new Player;

    key = 0;
    iframe = 0;

    srand(time(NULL));

    initscr();
    initColor();
    keypad(stdscr, TRUE);
    curs_set(0);
    nodelay(stdscr, TRUE);

    while (key != 'q' && player->getLife() > 0)
    {
        usleep(19000);

        clear();

        spawnStars(stars, iframe);
        spawnEnemy(ship, iframe);
        spawnAst(ast, iframe);

        displayText(player);
        displayEdge();
        displayStars(stars);
        displayEnemy(ship, player);
        displayAst(ast, player);
        displayBullet(bul, ship, ast, player);
        displayEnemyBullet(bulEn, ship, player);

        mvaddch(player->getX(), player->getY(), '>'|COLOR_PAIR(4));

        key = getch();

        refresh();

        if (key == 258 && player->getX() < 30)
            player->setX(player->getX() + 1);
        else if (key == 259 && player->getX() > 4)
            player->setX(player->getX() - 1);
        else if (key == 260 && player->getY() > 4)
            player->setY(player->getY() - 1);
        else if (key == 261 && player->getY() < 52)
            player->setY(player->getY() + 1);
        else if (key == 32)
        {
            i = 0;
            while (bul[i].getY() < 100 && i < 200)
                i++;
            bul[i].setX(player->getX());
            bul[i].setY(player->getY() + 1);
        }

        iframe++;
        if (iframe == 100)
            iframe = 0;
    }
    clear();
    refresh();
    endwin();
}
Exemplo n.º 4
0
//monster Attack function.  determines if monster hits and how much damage is done
int monsterAttack(int speed, int attack, string enemyType)
{

    //findhit is a booleon determined by whether or not thac0 roll is successfl
    bool findhit = thacoRoll(playersAC, speed);
    if (findhit)
    {

	//damageDealt is the output of the damage function which is then modified by the game's difficulty setting
        int damageDealt = damage(attack);
        if ((difficultySetting == "Medium") && (damageDealt < 100))
        {
            damageDealt = damageDealt + 10;
        }
        else if ((difficultySetting == "Medium") && (damageDealt >=100))
        {
            damageDealt = damageDealt * 1.5;
        }
        else if ((difficultySetting == "Hard") && (damageDealt < 100))
        {
            damageDealt = damageDealt + 25;
        }
        else if ((difficultySetting == "Hard") && (damageDealt >=100))
        {
            damageDealt = damageDealt * 2.5;
        }
        clearScreen();
        cout << menuBar << "\n\n";
        displayEnemy(enemyType);
        cout << "             You get hit for "<< damageDealt << " damage!\n\n";
        playerHealth = playerHealth - damageDealt;
	//on successful hit by monster a use is taken away from a random armor piece on the player
        srand(static_cast<unsigned int>(time(0)));
        int randomNumber = rand();
        int armorSelection = (randomNumber % 4);
        if (armorSelection == 0)
        {
            itemUses = player_ehelm[0][2];
            player_ehelm[0][2] = itemUses - 1;
            if (player_ehelm[0][2] = 0)
            {
                cout << findItemName(player_ehelm[0][0], player_ehelm[0][1]) << " has been destroyed!\n";
                player_ehelm[0][0] = 9;
                player_ehelm[0][1] = 9;
                player_ehelm[0][2] = 9;
            }
        }
        else if (armorSelection == 1)
        {
            itemUses = player_eplate[0][2];
            player_eplate[0][2] = itemUses - 1;
            if (player_eplate[0][2] == 0)
            {
                cout << findItemName(player_eplate[0][0], player_eplate[0][1]) << " has been destroyed!\n";
                player_eplate[0][0] = 9;
                player_eplate[0][1] = 9;
                player_eplate[0][2] = 9;
            }
        }
        else if (armorSelection == 2)
        {
            itemUses = player_egauntlets[0][2];
            player_egauntlets[0][2] = itemUses - 1;
            if (player_egauntlets[0][2] = 0)
            {
            cout << findItemName(player_egauntlets[0][0], player_egauntlets[0][1]) << " has been destroyed!\n";
            player_egauntlets[0][0] = 9;
            player_egauntlets[0][1] = 9;
            player_egauntlets[0][2] = 9;
            }
        }
        else if (armorSelection == 3)
        {
            itemUses = player_eboots[0][2];
            player_eboots[0][2] = itemUses;
            if (player_eboots[0][2] = 0)
            {
                cout << findItemName(player_eboots[0][0], player_eboots[0][1]) << " has been destroyed!\n";
                player_eboots[0][0] = 9;
                player_eboots[0][1] = 9;
                player_eboots[0][2] = 9;
            }
        }
        cout << "               Health is at "<< playerHealth << "!\n\n";
        if (playerHealth <= 0)
        {
            cout << "             Oh no!  You died!\n";
            cout << "      Press '1' to return to the Main Menu\n\n\n";
            cout << menuBar;
            cin >> playerchoice;
            return false;
        }
        cout << "              Press '1' to continue!\n\n\n";
        cout << menuBar;
        cin >> playerchoice;
    }