Jump to content
  • Advertisement
Sign in to follow this  
shadowfire36

menu help for game menu in c++

This topic is 3934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i m trying to build a turn based text game but im kinda of confused on the menu's ok here is my issue i want to have 4 menu's in my game menuDisplay selectMenu fightMenu shopMenu now what i want is the menuDisplay to be the welecome menu where the user make begins. the "the selectMenu " will display the fight ,save,shop and quit. ok her is my dilema is im tryin to figure out is how can i move from the switch to the next menu and continue into the next menu once a player has entered his name the two issues are what to i need to establish if .else or another switch maybe a do while? im not sure also , how can i code a ck to return if the user has selected his name properly example: user enters 'eric' i want it to say "eric is this correct" ? y- for yes n-no an be able to return if entered incorrectly
 
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
  ifstream loadFile;
  string playerName;
  char menuDisplay;
  char selectMenu;
  char letter;
	
   //menuDisplay

   cout << "Welcome to Space Gladiator Coliseum"
		 << endl;

   while (menuDisplay);
   {
//display menu 
     
      cout << "What would you like to do?" << endl;
      cout << "(enter the letter of your choice)" << endl;
      cout << "Press 'N' - To Begin a New Game"  << endl;
      cout << "Press 'L' - To Load a Previous Game " << endl;
      cout << "Press 'Q' - To Quit" << endl;
		
//choice
      cin >> letter;

    switch (letter)
     {
       case'n':
       case'N':
       cout << " Please Enter Your Fighters Name: " << endl;
       
       cin >> playerName;
			

       if ( playerName < 10 );
        {
          return playerName;
          cout << playerName << " Let's Begin " << endl; 
	}
	else 
         {
	cout << " You have exceed 10 characters for a name." << endl;
	cout << " Please Re-enter Name " << endl;

//problem------>
//how to return user name to see if correct
//how to move to next menu 
	}

	return 0;
	  }
    }

}

Share this post


Link to post
Share on other sites
Advertisement
use a loop eg


while(1)
{
cout << "Enter name: ";
cin >> PlayerName;
cout << "\n";//new line
if(valid(PlayerName)) break;
else cout<<"Invalid name. Please renter.\n";
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!