I never understood that error message until now.
Thanks Elysia! :D
Printable View
I never understood that error message until now.
Thanks Elysia! :D
You're welcome :)
Btw, it doesn't have to be a function. It can also be a variable, as you just witnessed. But it's the same in that it wasn't able to find it!
Also, if you're all curious, I'm working on getting rid of this mess:
I've decided to do some research on gamestates and I figure that I could easily simplify my code to something like this:Code:void Card_Game::play_game()
{
using namespace std;
int gameloop = 1;
int result = 0;
int controller = 0;
while (gameloop != 0)
{
IO::instance().clear_screen();
switch(controller)
{
case 0: // main menu
std::cout << "Welcome to the Casino!\n";
std::cout << "What would you like to do?\n";
std::cout << "1. Play Blackjack\n";
std::cout << "2. Quit\n";
result = IO::instance().get_input();
controller = main_menu(result);
if (controller == 4)
{
gameloop = 0; // end game
}
break;
case 1: // blackjack function
cout << players[0].show_hand();
std::cout << players[1].show_hand();
std::cout << "The current jackpot is " << pot->get_pot() << " dollars!\n";
std::cout << "\nWhat would you like to do?\n";
std::cout << "1. Hit me\n";
std::cout << "2. Stay\n";
std::cout << "3. Fold\n";
result = IO::instance().get_input();
controller = blackjack(result);
break;
case 2: // deal again?
for (unsigned int loop = 0; loop < players[0].hand->card_list.size(); loop++)
{
players[0].hand->card_list[loop].flip_card(true);
}
std::cout << players[0].show_hand();
std::cout << players[1].show_hand();
if (player_wins == true)
{
std::cout << "You win!!\n"
<< "You've won "
<< calculate_winnings()
<< " dollars!\n\n";
players[1].cash += calculate_winnings();
}
else
{
std::cout << "You Lose!!\n"
<< "You've lost "
<< pot->get_pot()
<< " dollars!\n\n";
}
std::cout << "Would you like to deal again?\n";
std::cout << "1. Yes\n";
std::cout << "2. No\n";
result = IO::instance().get_input();
controller = deal_again(result);
break;
case 3: // place bets
std::cout << players[0].show_hand();
std::cout << players[1].show_hand();
std::cout << "How much would you like to bet? You have "
<< players[1].cash
<< " dollars.\n";
controller = place_bets(IO::instance().get_input());
if (controller == 4)
{
controller = 3;
}
break;
}
}
}
Code:int main ( int argc, char *argv[] )
{
State_Manager state_manager;
// initialize the engine
state_manager.init();
// load the intro
state_manager.change_state( Menu_State::instance() );
// main loop
while ( state_Manager.running() )
{
state_manager.update();
state_manager.draw();
state_manager.handle_events();
}
// cleanup the engine
state_manager.cleanup();
return 0;
}
Wonders of classes, no?
YES, it's quite amazing, thats why I'm trying to make this work though, because the result is something close to perfection bwahhaha :D