Sign in to follow this  
EvilCloneVlad

RPG Game Loop

Recommended Posts

I'm trying to create a RPG just to learn my C++, so far all I have is a class for the player, and I don't exactly know what to do for the game loop. What I would like is when you start it the main menu would give you the choices for a New Game, Load Game, or Quit Game. If you select New Game it would ask for your character name and then randomly generate the character stats. Load Game would just load all th stats and Quit would well... quit. When your playing the game the menu would also have 3 choices and those would be to go to the Arena to fight a selectable creature, go to the store to buy items (potions and such) and then the third option to save the game. Like I said I don't really know how to go about setting up this type of loop so any advice or suggestions would be greatly appreciated. EDIT by the way this is all just a DOS based game so no graphics or anything like that since im still learning alot.

Share this post


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


//pseudo code
int 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 0
return 0;
//else if you go to Set up player function, return 1
return 1;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by EvilCloneVlad
EDIT
by 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").

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this