Public Group

RPG Game Loop

This topic is 4125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Share on other sites
Ok. This is what I generally do for my games:

//pseudo codeint game_state = 0;while(game is not over yet) {  switch(game_state)  {    case 0: game_state = Main_Menu();            break;    case 1: game_state = Set_Up_Player();            break;    ...    default: break;  }}int Main_Menu(){//do stuff//if still in main_menu, then return 0return 0;//else if you go to Set up player function, return 1return 1;}

Share on other sites
It would probably be better to use an enum, instead of just numbered states. (It may be better still to use polymorphism, but that can be left for another day).

Share on other sites
Quote:
 Original post by EvilCloneVladEDITby the way this is all just a DOS based game so no graphics or anything like that since im still learning alot.

Since you're a beginner, I'll point this out so that you don't get bitten by it later.

DOS is an operating system. If you're using Windows, what shows up is the command shell (cmd.exe) - it's not related to DOS in any way other than that it uses a text interface. The DOS shell can still be run (it's command.com) but you don't need, nor want, it for what you're doing.

You should avoid calling it DOS because, as you advance, this can introduce confusion as to what you actually mean (because, say, you might be writing a game that uses the DOS subsystem of Windows - or even a game specifically for DOS (which can be interesting because it offers only a little abstraction from the hardware)).

Also, C++ itself doesn't recognise the command shell (the Windows API does). It recognises something called the console - the command shell is one (common) implementation of this abstract concept. This console could be a connection over a serial port, a teletype printer and a keyboard, etc. Of course, in C++, the STDIN and STDOUT streams to which cin/cout are connected can be redirected (the most common one being the use of command shell 'pipes' whereby the output of one program is the input of another giving rise to expressions like dir C:\WINDOWS\system32 | find "calc.exe").

• 35
• 12
• 10
• 9
• 9
• Forum Statistics

• Total Topics
631358
• Total Posts
2999531
×