Updated date:

Creating a Game With Notepad

You probably won't know what all of this means right now, but I'll explain it soon.

You probably won't know what all of this means right now, but I'll explain it soon.

Introduction

Did you know that the simple Notepad program on your computer is actually a very powerful programming tool? That's right, and it is also very easy to learn. In this article I'm going to show you how to make a simple game using only the Notepad program and a programming language called "Batch."

Batch is a language that runs primarily out of your Windows command prompt. Now, it's not even close to being the most powerful programming language out there, but it still let's you do enough to be extremely useful to know (at least for anyone in the computer field).

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.

A Few Quick Reminders

I want to go over a few quick things before we get in to the actual code. The first thing is that all of your commands should be kept on separate lines. So after you type something in, and are done with what is going to be on that line, hit the "enter" button on your keyboard to move to the next line.

The second thing I want to mention is that batch files read from top to bottom. This means that when you run a batch file, all of your code at the top will be interpreted and will run before your code at the bottom. This concept is what allows some of the things I'm going to teach you, to work. If for example you place a "echo" command and in the next line place a "cls" command, all of your text will be erased without your player getting to read it (this will make more sense later on).

If you ever have a problem and your game isn't working correctly, make sure you go back and ensure that you haven't made any of these errors.

Starting Up Notepad

Let's start by opening up Notepad:

Click on your start menu icon and go to "All Programs." A list of all the programs on your computer should appear, along with a file called "Accessories." Go in to the accessories folder and you should find Notepad, click on it to begin.

You should find Notepad in the Accessories folder.

You should find Notepad in the Accessories folder.

Code!

Now you're ready to begin typing your first lines of code, as well as learning you first commands. Commands are each of the words that we type in to the program that have a function; such as the echo, or pause commands.

@echo off, echo, echo. and pause

The first commands I'm going to teach you are very simple, however, they play an important part in the coding process (especially if you're making a game!).

@echo off - This command is used to remove all of the unnecessary text that can interfere with your game. It should always be added first; once it is added to a file, it does not have to be typed in again.

echo - echo is used to display regular text 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 @echo off).

echo. - echo. (with a period) is used to create a blank line in your game. This can be useful in keeping your text uncluttered.

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. When you use this code it shows up as "Press any key to continue . . ." Your players can then press any key, when they are ready, in order to continue playing.

This is what your game should look like. Notice the long spaces between the text? This was done with the "echo." command. Also, note the pause command at work toward the bottom.

This is what your game should look like. Notice the long spaces between the text? This was done with the "echo." command. Also, note the pause command at work toward the bottom.

This is what your game should NOT look this. When you don't add "@echo off" this is what happens.

This is what your game should NOT look this. When you don't add "@echo off" this is what happens.

color 71 and "My Game" in the title bar.

color 71 and "My Game" in the title bar.

cls, exit, title, and color

Ok, this next set of commands are all really simple as well, but are nice to have.

cls - cls is a command that I use a lot. 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). This is a good tool when you want to keep your game looking clean and in order.

exit - This does exactly what it sounds like, it closes the 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.

title - title displays whatever you type after it in the title bar of the command prompt window.

color - color is a really fun command, and can be used to liven up your game. 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. For a list of the available colors see the picture below or open up the command prompt and type in "color/?".

You can access the command prompt by going back in to the accessories folder in the start menu. It should be in the same list as Notepad.

This is what you will get if you type "color/?" in to the command prompt.

This is what you will get if you type "color/?" in to the command prompt.

This is about what you should be capable of doing at this point.

This is about what you should be capable of doing at this point.

Let's Take A Break

Let's stop for a second and look at what we have so far. I've shown you several basic commands, and have taught you how to use them. Remember that each command should go on a different line (so hit "enter" after you finish with each command). Take a look at the picture to the right, so that way you can be sure that you know about what your file should look like.

goto

The "goto" command is simple, once you get to know it. The command is used when you want a player to jump to a different section of your game, such as when they make a certain decision.

It works this way:

You enter the "goto" command on a separate line, or at the end of an "if" statement (which we will go over later). You then specify a variable which will become the name of the destination. The name can be anything you want, and consists of the word(s) you type after "goto".

To specify your destination:

Move to a new line of code, directly above where you want your player to start. Type a colon ':' followed by the name of the destination.

example of a goto command.

example of a goto command.

set /p and if

These commands are the most advanced commands that I am going to teach you. They both have to be set up a specific way and also work with several other, smaller commands in order to function correctly.

set /p variable= - This command is used when you want your player to insert a variable (a varying answer). 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. Often times this variable will be referenced later, and therefore must be given a name. The name can be whatever you want it to be (but remember that you may be typing it in a lot when making your game). I think it would be easiest if I gave you some pictures showing you how to create variables.

set /p name=

set /p name=

See how I use the "echo" command to ask my player what his name is? I then go ahead and type:

set /p name=

This is where my player will type his name. "name" In this line is my variable. In a sense what we are doing is setting (set) a variable (name) to equal (=) whatever the user types.

We can reference this variable later by placing the name of the variable within two of the '%' symbols. For example:

echo Hello %name%, my name is Tom.

This will feed whatever the player typed in, back to him in the form of text.

Here is what happens when a player types in his name, then you feed that name back to him with the echo command.

Here is what happens when a player types in his name, then you feed that name back to him with the echo command.

if - this command is used when we create if/then statements. We can use it in conjunction with "set /p" in order to create choices for are players.

  1. Ask the player a question with the "echo" command. Make sure to clearly state their options.
  2. Give them the ability to enter an answer with the "set /p" command.
  3. Create "if" statements that allow the players' choices to have consequences, and that allow the story to continue.

"if" statements are used with "equ" and "neq" which mean "equals" and "doesn't equal", respectively.

This is how your statements should look:

:start

echo YES or NO?

set /p variable=

if %variable% equ YES goto situation1

if %variable% equ NO goto situation2

if %variable neq YES goto start

All of this code means that if the player types in "YES" he will be sent to "situation1"; if he types in "NO" he will be sent to "situation2"; if he types in neither "YES" or "NO" he will be sent back to the start of the question.

Remember when I said earlier that the order you write your code matters? If you typed in the "neq YES" code before the "equ NO" code, your player would never be able to make it to "situation 2".

Here is a good example of how you can use "set /p", "goto", and "if" all together.

Here is a good example of how you can use "set /p", "goto", and "if" all together.

Saving

The last thing I need to show you how to do is to save your file. Once you are all done, click the "file" button at the top of the screen, then click on "Save As." This will display a window where you can then create a name for you game and save it wherever you would like. However, you need to make sure that you save it as a Batch (.bat) file and not as a regular text file (.txt).

To do this, after you type in the name of your game add .bat behind it. You then need to go to "Save as type" and select "All Files."

Then you're done! All you have to do is hit the "save" button.

Remember, you can edit your game at any time by right clicking on the batch file and selecting "edit."

Select "All Files", then click the save button to finish.

Select "All Files", then click the save button to finish.

Conclusion

It's as easy as that! With only the few short commands that I taught you (@echo off, echo, cls, pause, color, goto, etc.) you can be on your way to making very large and complex text-based games. Always double check your code to make sure that you typed everything correctly, and if you have any questions feel free to leave a comment and I'll get back to you as soon as I can. Good luck and have fun!

Comments

Harith on August 20, 2020:

Thanks

Austin Rykhus on August 10, 2020:

You go into file hit save as then you put it in desktop thwn when you go into home youll see it it will have gears on it.

Aadim Gyawali on July 16, 2020:

Awesome !!!

Kai on July 03, 2020:

Thanks for the tips!!

@kelvin you must save the game with its name and the and at the end of the file name say .bat then save it open the file and it will run the game! :D

kelvin on July 02, 2020:

how can run the game

nathania on April 27, 2020:

pls may I have your number whasapp and phone

nathania on April 27, 2020:

nice

Someone on April 26, 2020:

Wow. It's a platformer or a quiz?

Anonymous on October 11, 2019:

As a newbie this helped a bunch so thanks but how do i do more advanced stuff like a 2d platform sidescroller, or even a wolf 3d style fps in notepad but thats a streeeeetch so thanks again.

ENGINEER G on August 13, 2019:

please how do i launch the game when am done sir

gospel on August 13, 2019:

how do i launch the game?

Gideon Asiak on July 07, 2019:

This is very useful. Thanks

fixed it on July 06, 2019:

@echo off

:home

title Road Trip by Numbers!

color 0f

cls

echo.

echo Welcome to Road Trip! What are the names of the people in your group

echo.

set /p name1=

set /p name2=

set /p name3=

set /p name4=

echo.

echo Road trips reguire lots of stuff! What stuff would you like?

echo.

echo 1) Samwich

echo 2) Amunition For Those Pesky Sasquaches

echo 3) Water To Stay Alive

echo 4) Band-Aids

set /p web=

if %web% == goto start

if %web% == goto start

if %web% == goto start

if %web% == goto start

echo.

pause

:start

cls

echo.

echo where do you want to go?

echo.

echo 1)New York

echo 2)Colorodo

echo 3)Canada

echo 4)Station

set /p game=

if %game% == 1 goto new

if %game% == 1 goto color

if %game% == 1 goto cana

if %game% == 1 goto station

pause

:station

cls

echo.

echo you got into a car crash

pause

exit

:new

cls

echo Some angry race car drivers pass you and %name4% wants to go as fast as them do you go as fast as them

echo.

echo yes

echo no

echo.

set /p meh=

if %meh% == yes goto death

if %meh% == no goto fit

:color

:cana

:fit

echo %name4% Is throwing a fit

pause

:death

cls

echo you got into a car crash

pause

exit

troler69 on June 21, 2019:

the only working option is station in it no good

BillyBobJoe on May 16, 2019:

I dont know why this code doesnt work, pls help!

@echo off

:home

title Road Trip by Numbers!

color f

cls

echo.

echo Welcome to Road Trip! What are the names of the people in your group?

echo.

echo TYPE NAMES HERE

echo.

set /p name 1=

set /p name 2=

set /p name 3=

set /p name 4=

echo.

echo Road trips reguire lots of stuff! What stuff would you like?

echo.

echo 1) Samwich

echo 2) Amunition For Those Pesky Sasquaches

echo 3) Water To Stay Alive

echo 4) Band-Aids

set /p web=Type option number

echo.

pause

:start

cls

echo Where do you want to go?

echo.

echo Newrok, Colorodo, Canada, Station?

echo.

set /p where=

echo.

if %where% equ Newrok goto newrok

if %where% equ Colorodo goto colorodo

if %where% equ Canada goto canada

if %where% equ Station goto station

if %where% neq Station goto start

:station

cls

echo.

echo You made it to the gas station and back with no trouble at all.

echo.

pause

exit

:newyok

cls

echo Some angry race car drivers pass you, and %name 4% wants to go as fast as them, do you go as fast as them?

set /p yes no

if %yes no% equ y goto car crash

if %yes no% equ n goto fit

:fit

echo %name 4% Is throwing a fit!

:car crash

cls

echo You got into a car crash

exit

PinkSheep on April 30, 2019:

Cool. Is there any other way to make other games that include arrow keys?

Begin Scripting on March 16, 2019:

i have seen that so much people are saying it is not working all you need to do is put .bat at the end of the file's name

boo on January 30, 2019:

try file name and end with .bat

shivam pandey on January 20, 2019:

how to open this game

ahmad on December 27, 2018:

thank you very umuch very c=very very very very much:)

sundar pichai on December 18, 2018:

good

Ansi on December 15, 2018:

I tried to do want you said(command)but it's just showing methe work that I did on notepad

yakubu halan on November 12, 2018:

please help i have done correctly as you command but it shows me

a black page with the copy of what i did in my notepad

devil sumeet on November 09, 2018:

continue bro u doing great nice

rejoanul on October 26, 2018:

Wow! I didn't know I could do that . This was my first coding experience. Thanks.

Robert on October 04, 2018:

Thank you very much your time and effort.

But how can you play your game after creating it in that file type?

arjun on September 11, 2018:

hi! i was sucesfull in making the game but how to make visual characters and put image,is notepad able to do so.....

Daniel Ratliff on September 06, 2018:

How do I add an inventory?

Baymax23 on August 11, 2018:

Hello , i am new to this and i got the game to work and was trying to modify it to my needs. Which would kind of act as a troubleshooting flow. I got to a part where I need to give "player " 4 options and for those options to have at least 3 options each but when I try to test it , Game recognizes only 1st option and its 3 other paths from there. .... is there a line or code that I might be missing. Is this even possible to have with notepad ?

Someone on July 30, 2018:

Cool tutorial.

Yashwanth on July 13, 2018:

i wanted a similar mini block game,can you provide me with its script

Guilherme on July 04, 2018:

For some reason whenever I use the command pause it always closes and I can't find what's causing it. I already tried everything.

Moo on July 03, 2018:

@Person You're not using the pause command to let the user read what you're typing on echo.

JOHN on June 23, 2018:

I type your code and save it but nothing appear someone tell me whats solution?

chisom on June 19, 2018:

How to assemble the Game code into mobile

application.

Psalms on June 01, 2018:

How to assemble the Game code into mobile application

noname on May 27, 2018:

could you continue the making the game please person

Person on May 21, 2018:

nvm on that comment. i saved as a .vbs instead of .bat.

I'm still having trouble. I made a name select screen and at the end it says YES or NO no works and takes you to the begenning but yes closes the game.

Person on May 20, 2018:

Can someone help? I tried opening my game and it didn't work. An error box just came up.

Here is the games code, can someone fix it for me?

@echo off

color 04

cls

title My game

echo.

echo Hello

echo.

echo What is your name?

echo.

set /p pname=

echo.

echo What is your best friends name?

echo.

set /p bfname=

echo.

echo Alright, choose my name

echo.

set /p nname=

echo.

echo Ok %pname%.

echo.

echo this is an early build.

pause

exit

Munashe on May 11, 2018:

Thank You.

This Helped Me So much

Aniasjasas on April 26, 2018:

when i make a name and press enter it closes the game

Anonymous on April 23, 2018:

it keeps closing if I press a key, even if i have text after it! Whats happening???

Muizz on April 08, 2018:

Thanks very much Alex king, it's fun learning from the basics.

save it as (title).bat on March 23, 2018:

save it as (title).bat

Aditya mahadev nalavde on March 23, 2018:

I have creat a new game in my notpad

manis on March 09, 2018:

how to make fighting game with images

ASIF A on March 02, 2018:

I WAS AN CEO OF AFSAGROUP OF INDUSTRIES TO RUN AN GAME TYPE THE WHOLE CODE AND SAVE IT AS GAME.DLV AND RUN.

Aditya on February 27, 2018:

Sir how will i run my game i'm not able to understand can you please tell me...?

Ali on February 26, 2018:

For who does not know how to open the game:

You must save it as a .bat

Bruno on February 20, 2018:

How to open that game?

Drax on February 17, 2018:

Please teach me more

ponnala prakash on February 12, 2018:

i dont understand the programme

Vin on February 12, 2018:

Thank you so much! You're great!

niko on February 12, 2018:

how can start the game

anonymous on January 19, 2018:

thank you so much this really helped me make a pretty cool game that I just love and now that you tought me I like to explore with all of this coding

ben on January 16, 2018:

i am a student ,i tell my teacher that she should teach us notepad program also

if you can continue this tutoral plssss continue

lalitha on December 22, 2017:

super super super.........!

otz on December 18, 2017:

super thankz

ACE on December 18, 2017:

AWESOME development

entah on December 14, 2017:

thanks for tutorial

GamerMTD on December 08, 2017:

How can we start the game

Grace on November 04, 2017:

I'm doing some work on the notepads. And I need to find the accessories folder please help me I'll be fine but you can tell me where it is please I'm. Going ok your find are you yes well I'll,say no to me

hfh on November 04, 2017:

what i have to do after completing the code you gave. can i open the game . if yes then how

Wisdom Pius on October 23, 2017:

Looks good

Matthew C on October 16, 2017:

IF YOU DIDN'T KNOW IT ILLEGAL TO DISTRIBUTE BATCH FILES OVER THE INTERNET

(Copy the text into notepad, save the file as (file name).bat to you desktop or wherever. Open The file, There you have it.)

I TOOK THE CONTENTS AND POSTED THEM HERE:

@ECHO OFF

color 21

:start here

cls

title Matthews Game

echo.

echo Hello Player!

echo.

echo What is your name?

echo.

set /p name=

goto start here

:start

cls

echo.

echo Where do you want to go?

echo.

echo SWAMP, TOWN, or MOUNTAIN?

echo.

set /p where=

echo.

if %where% equ SWAMP goto swamp

if %where% equ TOWN goto town

if %where% equ MOUNTAIN goto mountain

if %where% equ SWAMP goto start

:swamp

cls

echo.

echo ok! Let's head to the swamp!

echo

pause

exit

:town

cls

echo.

echo ok! Let's head to the town!

echo

pause

exit

:mountain

cls

echo.

echo ok! Let's head to the mountain!

echo

pause

exit

Julian on September 29, 2017:

This is amazing thank u so much

Abhay Shukla on September 27, 2017:

I want to how to open this game it is open with notepad

kumaresan on September 18, 2017:

how to create new game

ismail s jafo on September 03, 2017:

i got an idea

thank

sparky the cat190 on September 02, 2017:

paolo here is a example that builds it's data base as you talk to it to remove phrases you must edit the source code if you rename it you must change to file name where it saves new phrases to the new file name

https://drive.google.com/file/d/0B0vnvqSWWBTTWTN2N...

Paolo on September 02, 2017:

Is it possible to create an enciclopedy with this tecnique? I would like to create a file where the "game" invites you to ask for something and then answers your question. Sorry for my bad English...

Code.Me on September 01, 2017:

i like pizza

sparky the cat190 on September 01, 2017:

your welcome i found a problem under forest that i didn't see before i posted it you should change

if %lv% equ (greater than sign)5 goto fight6

to

if %lv% gtr 5 goto fight6

Mnooper on August 30, 2017:

Thanks sparky! really appreciate it

the game works just fine, and i am continuing to edit it to make it even better rn.

thanks again!

sparky the cat190 on August 29, 2017:

I don't know if you still need it or not but here is a working version of your game Mnooper

https://drive.google.com/file/d/0B0vnvqSWWBTTdkd6Z...

and here is a version were i added a couple things

https://drive.google.com/file/d/0B0vnvqSWWBTTbXB0R...

Mnooper on August 27, 2017:

Update to my last comment:

New, edited script with different problems.

In my last script I couldn't enter :town at all.

In the updated script, I can reach :atkshop but when i enter a weapon name the game crashes.

Secondly, I manage to get to :battle without problems. except, when i enter FIGHT, I one-shot the enemy, something that is not meant to happen. The rest works fine, (I believe, I haven't tested the full script yet)

here is the link to the script:

https://pastebin.com/XRvxtqZm

HELP

Mnooper on August 26, 2017:

I need help with my script!

I know that you need my script in order to help, but

1)It is over 8192 chars

2)It has greater/lesser than symbols, which are not allowed in comments.

so instead please follow this link:

https://pastebin.com/hjyLV8W5

i has my script in it

my problem is that whenever the script reaches :battle it crashes and i dont know why.

any help or tips? i will be checking daily.

Mnooper on August 26, 2017:

George, when you click 'Save as', rename your file to whatever you want to call it, and put .bat at the end, making sure it is saved with All Files. Hope this helps!

George on August 24, 2017:

what if when I saved it it's not a .bat file ? even if i saved it with ALL FILES ??? pls answer this

Mnooper on August 24, 2017:

I have seen a lot of people complaining that this 'isn't a real game' 'a waste of time' etc.

this is a TEXT BASED game, meaning that it only uses text to describe what is happening. If you want a game using graphics and controls, I recommend following either of the following links: https://unity3d.com/ or https://www.yoyogames.com/gamemaker

I have also seen a lot of 'how to test??!?!!?!'. First, save your work, preferably onto your desktop, as 'My Game.bat'. Second, double click the file you just created to run it.

A few comments say 'How to add characters' etc. you just make them up, then create dialogue as them any time in the script. You might want to change the color of the text for every different character that speaks (Note: you have to 'pause' inbetween each character talking, otherwise all the text will be the same color!)

hopefully this helps,

-Mnooper

Ahmad on August 20, 2017:

Wonderful! Clear and simple teaching. THANK YOU SO MUCH!

But how can I add audios and videos to notepad as I want to make a multiple choice e-test including listening parts. And kindly tell me how to make self graded ind include and save the data of the users side by side with their scores.

Brian on August 19, 2017:

Thanks! Because of this tutorial i made a game, and a program inspired by notepad; doodle pad!

thank you!

genesis solomon on August 15, 2017:

can i add a song to the program on notepad if yes how

muneeb on July 31, 2017:

good i like it

Aniket kumar on July 20, 2017:

its good

mayilen on July 19, 2017:

how do i start the game

Tony on July 15, 2017:

Thanks for this how can I make more efficient program

Alec M.M. on July 11, 2017:

Is it possible to make the game fullscreen?

nati on July 10, 2017:

Hi.

Can you help me after I do the code how can I test it plz. Help me

Hamzat on July 02, 2017:

If i want to add hello my name is omar how do i do it

Lance on June 21, 2017:

whenever I try to go to a scenario it just closes the screen. I've checked the code, its right, but it just closes the game

ryan on June 13, 2017:

how to creat esecute name for standart game for PC?

nandan on June 12, 2017:

awesome

Mnm on June 12, 2017:

Wow, This was a very goodd tutorial on how to create a game via notepad...But when I made one, it was like, I am not able to go In the second situation even I'd I type the second option... I have written all Codes in order...Plz help

Bilal on June 03, 2017:

Hey, so.

I don't understand the %where% part.

I made a little thing where the guy had to lie or tell the truth, and before closing, I receive a message saying "unexpected answer was given.

At least, I think that's what it said.

Ediare festus on May 31, 2017:

Is it only the notepad or cmd because i am seeing both cmd codes and notepad

VIVEK on May 28, 2017:

COOL

Abhishek sharma on May 27, 2017:

Can i write everything in small letter or i have to write with capital also

Ethan Redfern on May 26, 2017:

I knew you could do this but I just needed to be reminded of the set /p part, but thx anyway

Baozar on May 22, 2017:

Please I want to know if we can also add pictures and images. For example, can we add the picture of a mountain or a town or a swamp like in d example above??

Thanks in advance