0
menu option in game
so I'm trying to develop a simple text based risk game in c++. I'm not too advanced, as I just started learning it. I was wondering if there was a way to pull up a command, such as a different set of questions the user could select, anytime in the game. For example, if he wanted to look up instructions mid way thru the game, he could press "help" and it pulls up a menu.
2 Answers
+ 1
one way to do it is to run the game inside a do while loop. here is a pseudo code :
- make a variable named choice to store commands
-make a boolean variable named run = true
- make a function to display the help menu
- make a function to move to the next question
do {
cin >> choice
if( choice == "help") {
help_function()
}
if (choice == "next") {
next_question()
}
if(choice =="q") {
run = false
\\to quit the game
}
} while(run )
0
Ah. Thank you so much I've been looking around, but since I'm Midway through our c++ class, we haven't reached all the good stuff, and most things online contain more complex things.