What I am trying to make is an opening menu for a game. It's in working condition but not ideal. I listed most of the menu options as cases in a switch. I'm just more comfortable using switches then if and else. I planned to put for loops around it and only escape them by pressing the number 4 and ENTER. What I was trying to do was give the player the ability to go back to the previous menu. Like in a real game by pressing O or something. I tried various for loops and breaks and continues but it always ends up a mess. Is the for loop the wrong path?
Please use code tags and proper indentation. Long and nested code is a pain to look at when it's like this.
I'd suggest to wrap every menu inside a loop, then:
- before each switch, put and if with a break inside that is executed if the"go back" input in given. Since it's outside of the switch it will affect the loop execution
Or
- use a bool to control if the loops must execute. When you want to go back set the value to false
I'm not really sure about how you want to control the flow of the menus, so these two provide a very basic solution
Maeriden is a genius. I wrapped the whole code in a for loop then put if, else before each switch. Now whenever the number four is entered it brings the user back to the first menu. I'm still working on making more nested loops within but the break keyword doesn't seem to exit the for loop. Perhaps because it's within the switch it thinks the break is meant for the switch rather then the loop? Anyways, this was a great accomplishment. Thanks again!