how do menus in games work?

I implying in the sense that in games on ps3 and 360, the player can easily press back and go forth easily.

Whereas, In comparison, in my menus (c++ console) I have to use a loops that only loop again if there is a wrong move, otherwise the player has to way until all my nested loops and choices are looped again.

E.G.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
main game loop
{


yes or no (USER CHOICE)

path yes      path no
()               ()

afterwards loop can either be terminated or looped again


//the issue here is that the player can't go back
//the only choice for a second chance is another loop

}
Last edited on
Need some more info to answer this. Why do you have so many nested loops? Let's see some code. If you are running into a situation where you have a fairly large decision tree, you don't want to go overboard with nesting or you are forced to continue through unnecessary execution. Remember however that you can always break completely out of the loop with the break; statement or break out and continue the next iteration with the continue; statement.

Menus in games are handled by states and depending on various menu states, mouse coordinates, etc... every frame the correct graphic is displayed. This is not something easily replicated on the console or IMHO recommended to attempt.
my code is fine, there are no errors, I've done thorough testing and it works.

but anyway, what are these states, I'm wondering how they implement the classes on them
Last edited on
The main problem is that console programming and game programming are vastly different.

Obligatory link: http://cplusplus.com/forum/articles/28558/


anyway nested menus are typically just done with function calls:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void MainMenu()
{
  while( user_is_in_main_menu )
  {
    Do_Frames_of_Main_menu_here();

    if( user_selected_Sub_Menu_A )
      SubMenuA();
    else if( user_selected_Sub_Menu_B )
      SubMenuB();
  }
}

void SubMenuA()
{
  while( user_is_in_this_menu )
  {
    Do_frames_of_sub_Menu_A_here();
  }
}


When SubMenuA exits, flow returns to the main menu.
The main problem is that console programming and game programming are vastly different.

Obligatory link: http://cplusplus.com/forum/articles/28558/


anyway nested menus are typically just done with function calls:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void MainMenu()
{
  while( user_is_in_main_menu )
  {
    Do_Frames_of_Main_menu_here();

    if( user_selected_Sub_Menu_A )
      SubMenuA();
    else if( user_selected_Sub_Menu_B )
      SubMenuB();
  }
}

void SubMenuA()
{
  while( user_is_in_this_menu )
  {
    Do_frames_of_sub_Menu_A_here();
  }
}


When SubMenuA exits, flow returns to the main menu.
thanks so much mate, I always felt console programming was weird but after I so a window32 video I learned that it all about massage loops.




Anyway, isn't Open_GL superior for working with graphics?
And also whats the learning curve for in cooperating Open GL with win32?
Last edited on

Anyway, isn't Open_GL superior for working with graphics?


SFML uses OpenGL. It's basically a wrapper to make it easier to use for 2D work, but underneath it all it's the same thing.

You can use OpenGL directly along with SFML. I would recommend starting with SFML since it's easier, then you can transition into OpenGL as you feel more comfortable with it.


Also OpenGL is just graphics, but SFML does a bunch of other stuff, like audio, input, window management, networking, etc, etc.

And also whats the learning curve for in cooperating Open GL with win32?


Honestly I don't have the foggiest idea. I've always tried to avoid working with Win32 directly since it destroys portability.

libs like SFML take platform specific issues away from you so you don't have to worry about these kinds of things. It makes it easier overall and keeps it cross platform.
Thanks I'll have to check with my lectures with regards to SFML, anyway thanks for the enlightenment
Topic archived. No new replies allowed.