This article will show you how to create a simple text game from the command line on a Windows computer.
Steps

Step 1. Open Notepad
Notepad is a free text editor included with all versions of Windows. Use Notepad to enter programming code. To open Notepad:
- Open the start menu
-
Windowsstart - Enter notepad.
- Click Notepad at the top of the menu.

Step 2. Enter the name of the game
Copy the following text into Notepad - instead of [Title] enter the name of the game, and then press ↵ Enter:
@echo off title [Title]

Step 3. Decide on the color of the text and background of the game
To specify the color, you must enter a code in the format "0A", where "0" is the background color and "A" is the text color. Common color codes:
- Text Color - Use the letters A, B, C, D, E, or F to represent light green, light blue, light red, light purple, light yellow, or white, respectively.
- Background Color - Use numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 to represent black, blue, green, aqua, red, purple, yellow, white, gray, or cyan, respectively.
- For example, to create white text on a black background, enter the code "0F".

Step 4. Set the colors of the game
Copy the following text into Notepad - instead of "0A" enter the desired combination of background and text colors, and then press ↵ Enter:
@echo off title Flash game color 0A if "% 1" neq "" (goto% 1)

Step 5. Create a game menu
It will be displayed after starting the game. Copy the following text into Notepad, then press ↵ Enter:
: Menu cls echo 1. Start echo 2. Thanks echo 3. Exit set / p answer = Press the key with the corresponding number and then press Enter: if% answer% == 1 goto Start_1 if% answer% == 2 goto Credits if% answer% == 3 goto Exit

Step 6. Set the "Exit" option
This will allow players to exit the command line. Copy the following text into Notepad, then press ↵ Enter:
: Exit cls echo Thanks for playing! pause exit / b

Step 7. Set the "Thank you" option
Copy the following text into Notepad (replace [Title] with the name of the game), then press ↵ Enter:
: Credits cls echo Thanks echo. echo Thanks for playing [Title]! pause goto Menu

Step 8. Set the "Start" option
It will allow players to start a new game:
: Start_1 cls echo Oh no! You are surrounded by enemies. echo There are five of them and they are all armed. echo If you fight them, you have a chance of winning. set / p answer = Fight or run? if% answer% == fight goto Fight_1 if% answer% == run away goto Run_1 pause

Step 9. Enter the action code
Enter the following code to set the game action:
: Run_1 cls echo You survived to fight another time. pause goto Start_1: Fight_1 echo Prepare for a fight. echo Enemies suddenly attack you. set / p answer = Press 1 and then press Enter. if% answer% == 1 goto Fight_1_Loop: Fight_1_Loop set / a num =% random% if% num% gtr 4 goto Fight_1_Loop if% num% lss 1 goto Fight_1_Loop if% num% == 1 goto Lose_Fight_1 if% num% == 2 goto Win_Fight_1 if% num% == 3 goto Win_Fight_1 if% num% == 4 goto Win_Fight_1: Lose_Fight_1 cls echo You have lost. Play again? pause goto Menu: Win_Fight_1 cls echo You've won! set / p answer = Do you want to save the game? [y / n] if% answer% == 'd' goto 'Save' if% answer% == 'n' goto 'Start_2': Save goto Start_2

Step 10. Open the File menu
It's in the upper left corner of Notepad.

Step 11. Click Save As
This option is on the File menu. The "Save As" window will open.

Step 12. Enter a name for the file and then enter the extension ".bat"
In the File Name text box at the bottom of the window, enter any file name, and then enter the.bat extension to save the game as a batch file.
For example, to name the game "Dungeon Crawl," enter Dungeon Crawl.bat

Step 13. Change the file format
Click the File Type menu at the bottom of the window, and then select All Files from there.

Step 14. Save the game to your desktop
To do this, click on "Desktop" in the left pane. You may need to scroll up or down the panel first to find the Desktop folder.

Step 15. Click Save
It's a button in the lower right corner of the window. The game will be saved as a BAT file.

Step 16. Start the game
Double-click the BAT file to open the game in the command line, then follow the instructions on the screen.
For example, press "1" to start the game

Step 17. Change the game code
Now that you've written the main code, you can make changes to it, such as adding parameters and more.
- To edit the game's code, right-click on the BAT file and then select Edit from the menu. Make your changes and press Ctrl + S to save them.
- Be sure to look at the code to figure out what each line is responsible for.
Advice
- If you want to use a more advanced code editor, download and install Notepad ++ and then create a BAT file in it.
- To display text on the screen, enter the echo command before the text.
- Play the game even if it's not completely finished; this will help you figure out what text is on the screen and you can find errors or typos.
- Batch BAT files are used in Windows to automate tasks, but writing a text-based game like this is a way to learn how they work.
Warnings
- Check the program code before transferring the BAT file to other people.
- Do not download or run BAT files obtained from questionable sources, as they may contain viruses.