We can use it in conjunction with "set /p" in order to create choices for are players. If - this command is used when we create if/then statements. We can reference this variable by placing the name of variable between %.Eg. The name can be whatever you want it to be. Often times this variable will be referenced later, and therefore must be given a name. This could be anywhere from their name to the name of a weapon or even the answer to one of the choices you have given them. Set /p variable= - This command is used when you want your player to insert a variable (a varying answer). These commands are the most advanced commands that I am going to teach you. It is a set of two numbers.First number is background color.Second number is font color. For a list of the available colors see the picture below or open up the command prompt(cmd) and type in "color/?". When you add the color code, followed by a space and a specific set of numbers or letter, you can change the colors of the command prompt window. Title - title displays whatever you type after it in the title bar of the command prompt window.Ĭolor - color is a really fun command, and can be used to liven up your game. You should only use this when the characters reach the end of the game, or if you want the game to close when they die or make a wrong decision.
This is a good tool when you want to keep your game looking clean and in order.Įxit - This does exactly what it sounds like, it closes the game. It stands for "clear screen", and what it does is remove all of the text that has been made in the command prompt window (ergo, making the screen blank). Ok, this next set of commands are all really simple as well, but are nice to have.Ĭls - cls is a command that I use a lot. " Your players can then press any key, when they are ready, in order to continue playing.
When you use this code it shows up as "Press any key to continue. Pause - This command is used when you want your players to take a break, and is used most often when you want to give them time to read some text. This can be useful in keeping your text uncluttered. (with a period) is used to create a blank line in your game. For example you can type: "echo Hello adventurer!", and the people playing your game will see is "Hello adventurer!" (So long as you typed in off).Įcho. Commands are each of the words that we type in to the program that have a function such as the echo, or pause commands.Įcho - echo is used to display regular text in your game.
Batch is a language that runs primarily out of your Windows command prompt.Not only is it useful, but it can also be used to create amazing text-based games! What is a text-based game you ask? It's a game (a very simple one) in which the user interacts through the use of text and choice-making.You will learn how to set up situations in which the characters will have to make choices about how they want to approach the problem.Ĭode! Now you're ready to begin typing your first lines of code, as well as learning you first commands.