Sign in to follow this  

menu help for game menu in c++

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;

   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;
      cin >> letter;

    switch (letter)
       cout << " Please Enter Your Fighters Name: " << endl;
       cin >> playerName;

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

//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
use a loop eg

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this