So i'm developing a simple graphical Sudoku game. As most application I have the standard loop
while (window.isOpen()){
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
if(menuChoice == 0) {
menuChoice = mainMenu.handleEvents(event, window);
}
window.clear();
if(menuChoice == 0) {
mainMenu.drawMainMenu(window);
}
As you'll notice from the code sample above i have two if statement if menuChoice == 0 The first decide what to draw based on the users choice in the main menu. The second says to draw the main menu if the user has not chosen any option yet.
Is there any good way of getting rid of this double if structure and still achieve the same goal?