// Entry point
int main(int argc, char *argv[])
{
init();
currentstate = GAME;
//Main loop: loop forever.
while (Done != 1)
{
switch(currentstate)
{
case START:
//Start();
break;
case GAME:
game();
break;
case MENU:
//MainMenu();
break;
case INSTRUCTIONS:
//Instructions();
break;
case BATTLE:
//create new battle if battle hasn't started
if(battle_begun == false)
{
Battle Melee;
battle_begun == true;
}
showBattle(Melee);
break;
}
}
//Shutdown();
return 0;
}
//fight battle with monster
void showBattle(Battle& Melee)
{
// Make sure nothing from the last frame is still drawn. //
clearScreen();
if ( (SDL_GetTicks() - g_Timer) >= FRAME_RATE )
{
//draw the battle screen
drawIMG(Melee.surBattleImage,BATTLE_SCREEN_X,BATTLE_SCREEN_Y);
//display battle main text
string battleText = "You have encountered a " + Mob.name + "!";
displayText(battleText,200,155,15,255,255,255,16,17,48);
//display battle instructions
string battleInstructions = "Click a number below to perform an action";
displayText(battleInstructions,163,220,15,255,255,255,16,17,48);
//display battle action text
displayText(Melee.strBattleActionText,200,175,15,255,255,255,16,17,48);
//only allow player to use keyboard on their turn
if(Melee.player_turn == true)
{
handleBattleInput(Melee);
//display battle player choice - Attack
string battlePlayerAttack = "1 - Attack";
displayText(battlePlayerAttack,163,250,15,255,255,255,16,17,48);
//display battle player choice - Run
string battlePlayerRun = "2 - Run";
displayText(battlePlayerRun,163,270,15,255,255,255,16,17,48);
//display battle player choice - Drink Potion
if(Hero.potions > 0)
{
string battlePlayerPotion = "3 - Drink Potion";
displayText(battlePlayerPotion,163,290,15,255,255,255,16,17,48);
}
}
else
{
cout << "test" <<endl;
}
// Tell SDL to display our backbuffer. The four 0's will make //
// SDL display the whole screen. //
SDL_UpdateRect(g_Window, 0, 0, 0, 0);
// We've processed a frame so we now need to record the time at which we did it. //
// This way we can compare this time the next time our function gets called and //
// see if enough time has passed between iterations. //
g_Timer = SDL_GetTicks();
}
}