I'm making a simple text-based RPG, where the player is the owner of five creatures that battle other teams for loot, experience and glory. I am using Python, and a curses emulator. I have a static ASCII over-world map. My character, represented by a glyph, can move about this static map. There are locations all over the map that the character can visit, that break down into two categories:

  1. Towns, which are a series of menus that will allow the player to buy equipment for his team, hire new recruits or do other things.

  2. Arenas, where the player's team will have a "battle" interface with actions he can perform, messages about the fight, etc. Later, I may include an ASCII representation of the fight; but for now, just screens of information, with action prompts, will be displayed.

What kind of design or structure should I use to implement movement between an over-world map and a menu system?

Right now, the game goes through a master loop that waits for keyboard input, and then moves the player about the screen. Upon keyboard input, the player coordinates are checked against a list of location objects, and if the player coordinates match a locations coordinates, then... I am not sure.

I'm not sure if I should call a separate function, to initiate either a menu or combat mode, or if I should create some kind of new GameMode object that contains a method for drawing the screen and printing the necessary info. If I go that way, I am not sure how to pass my players team data into this object.

My main concern is passing around the program flow into all of these objects. Should I be calling straight functions for different parts of my game, and objects to represent "things" within my game? I was reading about the MVC pattern, and how this kind of problem might benefit from decoupling the GUI from the game logic and user input, but I have no idea how this applies to my game.

  • 1
    \$\begingroup\$ Just use a state machine? \$\endgroup\$
    – Tili
    Feb 22 '12 at 8:35

You make a base class called GameState, or GameLevel. Store it as a reference or pointer. When game need to go into a battle (as in final fantasy style), you put your gamelevel type into a stack, and put the battle screen as the current gamelevel.

When you finish the battle, switch the references again. Of course, each type of level (town, over-world, battle) are (is a) sub-classes of GameLevel.

Also, remember to pause the stored GameLevels if necessary. With this system you could implement easily a system with a lot of submenus and exit from each one by pressing the escape key.

  • \$\begingroup\$ xnagpa.net/xna4rpg.php describes a way of implementing GameStates in order to accomplish such things, but it's for XNA. \$\endgroup\$
    – Superbest
    Feb 23 '12 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.