ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Creating a menu in an RPG/MUD game with batch script

Updated on August 11, 2012
Source

In this article, I'm going to walk you through creating a basic menu for your MUD/RPG game in batch script.This will be the very first thing users will see when they start your game. Keep in mind, you can always customize your game to show an intro before menu selection much like today's current games if you wish to do so. In this article, we're going to create the menu, and once the player starts the game, they will then be taken to the intro we have created for the game.

If you are wondering what a MUD game is. MUD stands for "Multi-User Dungeon" which was the first virtual world ever created by Roy Trubshaw in 1978. MUD games evolved over the years but they originally only consisted of text and ASCII art for graphics. As technology advanced, 2D art and 2D game worlds were eventually incorporated into MUD games. Meridian 59 was the first MMORPG (Massively Multiplayer Online Role-Playing Game) to incorporate MUD-style text within a 3D world.

Creating the menu

Batch script can be written entirely from within Notepad so to create the game menu for our game, we're going to start by opening Notepad on the computer. Once you have Notepad open, click File, then select Save As and change the Save as type to All Files. Create a name for your game, and use that as the filename. Let's say the name of your game is called "Dragon Hunter". You would create the filename as dragonhunter.bat. It's important you put the .bat as the extension on the end. This is batch scripts file extension and it works like an executable file. Once you double click on it, it will execute it's code or commands. In this case, we are viewing the .bat file through Notepad and writing the code for the game in it. When we save the dragonhunter.bat file in Notepad, we can then test out the results by double clicking on the dragonhunter.bat file which will execute the commands we wrote.

Now that the file is saved, we can begin writing the code for the main menu of the game.

Code Example:

@ECHO OFF
:MAIN_MENU
echo.
echo.
echo.
echo Welcome to Dragon Hunter!
echo.
echo To start a new game, type NEW and press ENTER.
echo To see instructions for the game, type INSTRUCTIONS and press ENTER.
echo To quit, type QUIT and press ENTER.
set /p input=What do you want to do?
if %input%==new goto INTRO
if %input%==instructions goto INSTRUCTIONS
if %input%==quit goto EXIT

Code Breakdown:

  • @ECHO OFF - If set to ON, this would show all of your code that you write.You always want to start the beginning of your batch scripts with @ECHO OFF unless you want your code to be shown, which 99% of the time you won't want it to be.
  • :MAIN_MENU - This is a label that we can reference later to jump to different points in the game. For instance, if a player views your instructions screen and wants to return to the main menu, we will be able to reference this label to send them back to the main menu screen. Any time you are creating a new section for your game, you'll want to create a label for that section. To create a label, type a colon (:) and then type the name of your label after it. Make sure to use underscores in between spaces for the label name so it's easy for the program to navigate to.
  • echo. - This code creates a break on the line as if you were pressing the enter key in a word document multiple times. Each echo. counts as pressing enter once as in Microsoft Word. The reason for putting this in is so that our title for the game isn't at the very top of the screen.
  • echo Welcome to Dragon Hunter! - This is the title for the game. Any text that is typed after the code echo will be displayed.
  • echo To start a new game, type NEW and press ENTER. - We are now building the menu options for the player to select from. You can deviate from what I have used above and create your own options. For instance, if you want to have the player just press number keys, then you can change the text to the following: To start a new game, press 1 then press ENTER. Use your imagination.
  • echo To see instructions for the game, type INSTRUCTIONS and press ENTER. - This is the second menu option for the game. Each game should have an instructions page that gives the learner an idea of the instructions or controls for the game. You can come up with your own keys for the players to press. For a MUD game experience, I prefer to have players type out what they want to do. IE: Typing instructions to view the instructions.
  • echo To quit, type QUIT and press ENTER. - The third and final menu option of our basic game menu. Each game should also have a quit option so that you can exit the game from the main menu.
  • set /p input=What do you want to do? - This code will ask the player what they want to do and requires an input from the player. In this case, the player has the option to type three different things: New, instructions, or quit.
  • if %input%==new goto INTRO - With this code, we are saying, if input equals "new", then goto the label "INTRO". We haven't created the intro label yet but you will want to eventually create a label (:INTRO) that the program will jump to when the player types in "new" and presses enter.
  • if %input%==instructions goto INSTRUCTIONS - With this code, we are pointing learners to the INSTRUCTIONS label which we haven't created yet at this point. You will want to eventually create a label (:INSTRUCTIONS) that the program will jump to when the player types in "instructions" and presses enter.
  • if %input%==quit goto EXIT - With this code, we are pointing learners to the EXIT label which we haven't created yet. The only code that will be displayed under the exit label is "exit" which will end the batch script and game.

Starting a new game

Now that we have our menu built for the game, we can have users start playing the game by typing "new" and pressing enter.

In the menu code, we wrote: if %input%==new goto INTRO. We want to create a new jump-to label for INTRO. See the code example below:

Code Example:

:INTRO
cls
type ASCII_Intro.txt
echo It was a dark and stormy night....
pause >nul
goto CHARACTER_CREATION

Code Breakdown:

  • :INTRO - This is the label and jump-to point for the introduction for the game.
  • cls - Almost always clear the screen after a jump-to label.
  • type ASCII_Intro.txt - We can display ASCII text art to set the mood for the intro.
  • echo It was a dark and stormy night.... - Write your story with one or multiple echo(s)
  • pause >nul - This code will pause the screen and not display any text asking you to "press any key to continue." It is suggested that you tell the learner to continue with an echo command.
  • goto CHARACTER_CREATION - Now that the into is over with, we can direct the player to character creation. We could start by asking them gender, class, race, etc. Remember, make a jump-to label for everything! Write down the order you want your game to go in and then follow the order you've laid out.

Instructions

Instructions to a game are important, however they may not be completely necessary depending on the game you are making. If you wish to create an instructions screen, it's fairly simple. Open a new Notepad document and save the file as instructions.txt. Write all of your instructions for your game in that notepad document and save the file in the same folder as dragonhunter.bat. Add the following code in bold:

Code Example:

:INSTRUCTIONS
cls
type instructions.txt
echo.
echo.
echo To return to the main menu press ENTER.
pause >nul
goto MAIN_MENU

Code Breakdown:

  • :INSTRUCTIONS - jump-to label for the instructions.
  • cls- clear the screen before displaying any text for a clean transition.
  • type instructions.txt - This will display any text written in your instructions.txt document.
  • echo. - A space to center or move text down further in the window.
  • echo. - A space to center or move text down further in the window.
  • echo To return to the main menu press ENTER. - We're telling them to press enter when they are ready to return to the main menu if there's a lot of text to read they may not be ready to return yet.
  • pause >nul - This pauses the screen with no text asking to press a key to continue. (You could remove the echo above where we state to return to the main menu, and instead add the code "pause" which would then prompt the learner to press a key to continue when they are ready. It's optional and depends on what your visual preference is.
  • goto MAIN_MENU - We're telling the program to return to the main menu after they press a key on the instructions screen.

Exiting the game

As stated earlier, the EXIT label is pretty straight forward. We are simply telling the program to quit by the "exit" command.

Code Example:

:EXIT
exit

Code Breakdown:

  • :EXIT- Jump-to label for quitting the game.
  • exit - Code which tells the game to quit.

Adding color

Adding color to your game window is fairly simple. See the below chart for color codes:

1-9 = Background Color
0=Black
1=Blue
2=Green
3=Aqua
4=Red
5=Purple
6=Yellow
7=White
8=Gray
9=Light Blue

A-F = Text color
A=Light Green
B=Light Aqua
C=Light Red
D=Light Purple
E=Light Yellow
F=Bright White

Let's say you wanted a gray background with white text, you would add the following code in bold:

@ECHO OFF
:MAIN
cls
color 8F
echo.
echo.
echo.
echo Welcome to Dragon Hunter!

Source

Adding ASCII art

You might be wondering what ASCII art is. ASCII stands for American Standard Code for Information Interchange. Basically, ASCII is a wide variety of text characters and symbols which can be used to create text art.Text art is simply arranging many different characters together through many lines and spaces to create an image. You can use ASCII art to create art for your MUD/RPG game which can be displayed on every page. For instance, you may want to have one ASCII text art image of your main character displayed whenever it's his turn to fight in a battle. Whenever it's the monsters turn to fight, you could display entirely different text art for that monster. You could even go as far as creating different art for each monster type.

Adding ASCII art is a little bit more difficult. The first thing you want to do is create a new Notepad document and save the file as something which indicates it's going to be ASCII text art. IE: ASCII_Goblin.txt. You can either try to type different symbols and characters to try and create the image you are going for in text, such as a Goblin perhaps, or you can also use Picture to ASCII Art generators to save you from creating one from scratch. Some of these generators don't work very well but it's worth looking to see what's out there.

Once you have your ASCII text art image created, save the file in the same folder as your dragonhunter.bat file. You will need to add the following code in bold to your game:

@ECHO OFF
:MAIN
cls
type ASCII_Goblin.txt - This tells the game to display whatever is in the text document.
color 8F
echo.
echo.
echo.
echo Welcome to Dragon Hunter!

Final Code and thoughts

By now you should have some understanding as to how batch scripting works. You can use the commands you've already learned and continue to build your game. You could start by figuring out what kind of character creation screens you would like to have. Do you want users to select a gender, race, class, or maybe choose a location where they originated from for some backstory? These are questions you should ask yourself. Don't be afraid to make any mistakes. If something doesn't work or feel right, change it!

There is more work to be done to creating a MUD/RPG game in batch script but you are well on your way!

Final Game Menu Code:

@ECHO OFF
:MAIN
cls
type ASCII_Goblin.txt
color 8F
echo.
echo.
echo.
echo Welcome to Dragon Hunter!
echo.
echo To start a new game, type NEW and press ENTER.
echo To see instructions for the game, type INSTRUCTIONS and press ENTER.
echo To quit, type QUIT and press ENTER.
set /p input=What do you want to do?
if %input%==new goto INTRO
if %input%==instructions goto INSTRUCTIONS
if %input%==quit goto exit

:INTRO
cls
type ASCII_Intro.txt
echo It was a dark and stormy night....
pause >nul
goto CHARACTER_CREATION

:INSTRUCTIONS
cls
type instructions.txt
echo.
echo.
echo To return to the main menu press ENTER.
pause >nul
goto MAIN_MENU

:EXIT
exit

Comments

    0 of 8192 characters used
    Post Comment

    • profile image

      rx.anns 20 months ago

      Nicely

    • profile image

      LOL 22 months ago

      ..is taht true?

    • profile image

      MIKE KOK 22 months ago

      I created a rage game with characters and a menu. YAY but how do I make my ASCII characters walk??????? KappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappaKappa

    • profile image

      bleh 22 months ago

      gjhgfjhfdgljhdjfkghfggggggggggggggggggggggggggggggggggggggggggggggskh

    • profile image

      ujjwal (virus maker) 2 years ago

      Oh my god!!!!!! It works!!!! It works!!!! This is amazing!! But, to make charters is very very and very difficult!!!! Uh. By the way its good I have created a game after learning this post. And my game is STREET FIGHTER VS DRAGON HUNTER