How to make a text game with notepad!

Leave a Comment
 
So, I'm sure alot of people look at minecraft and think how awesome it would be to make a game, except just using computer resources, and being able to get right into developing after a little practice. Well then you have come to the right place! Let's get right into it! Note that I don't believe it works on mac. Sorry, mac users.

You will need:


-A computer
-Notepad
-A good idea


The basics



We are gonna be coding in batch, an extremely simple coding language. Don't expect to have any music or images, just text, however you can add colour to the text and background. The first thing you should type is @echo off, trust me you will need it. Next let's do a title. Just type "TITLE [Title here]" I'll call mine "Cupcake" ( Don't ask why I did, I just did ).Heres how it should look:

@echo off
TITLE Cupcake

Now let's add a new section! Skip a line and put a : before anything.  A very important command should be added to every section and always be first which is called "cls". If you don't, all your text will pile up on the one screen. Here it is now

@echo off
TITLE Cupcake

:Menu
cls

Writing the code



There we go! Now let's add some actual text. Type echo to have text there. If you want to skip a line type "echo." No, that dot on the echo is not a fullstop for the sentence, it's what you need to type. If your gonna make a game you got to have a few options somewhere so let's add some for Starting, and exiting. A helpful thing is to convert a image to text! Just go into any photo editing program (Yes, even MS Paint) and type "Menu" or something up in a fancy font (The best things you could do is have the text black and the file as a .jpeg) then go to  and do your stuff! (Not required). Ok so now let's take a look about how the .bat file looks now! (The menu text is messed up on this blog, so I won't include it on my file).

@echo off
TITLE Cupcake

:Menu
cls
echo Hello, welcome to the greatest cupcake of all time!
echo What would you like to do?
echo.
echo 1.Start
echo 2.Exit
echo.

Right now the player can't type anything, and if you open the file it will close in a flash. Let's add in an input! Type
"set /p input=[Anything here]" Now the user can input, but it will do nothing and close the file. Let's make it so that typing "1" or "2" or "Start" or "Exit" will work. Type "If "%input%"=="[Insert text here]" [Insert command here]. So there is quite alot of "Insert here stuff" Basically if you type "1" or whatever in there it will run the Specified command in the second box. This can start an app, create folders and stuff, but we are making a game so we won't need it to run anything else. If your making a text game mainly on the second blank spot you will be using goto "section" (Sections are the things like :Menu). As for the exit option all you need to type is exit in the command. Now let me edit up my batch file.....Ok! Here is the file so far!

@echo off
TITLE Cupcake

:Menu
cls
echo Hello, welcome to the greatest cupcake of all time!
echo What would you like to do?
echo.
echo 1.Start
echo 2.Exit
echo.
echo Type "1" or "2" to do their respective uses
echo.
set /p input=Enter:
if "%input%"=="1" goto
if "%input%"=="2" exit

While only typing "2" works right now, you can still run it! Check above photos for it in action. Now I think it's about time we add a new section. Let's make this game ask for what to call you. But first we gotta add an "Invalid" section, otherwise typing something that is not "1" or "2" will take you to the name. Also use a command called "pause>nul" it will make it so that if you press any key any commands after that will activate. Let's add all that stuff now.

@echo off
TITLE Cupcake

:Menu
cls
echo Hello, welcome to the greatest cupcake of all time!
echo What would you like to do?
echo.
echo 1.Start
echo 2.Exit
echo.
echo Type "1" or "2" to do their respective uses
echo.
set /p input=Enter:
if "%input%"=="1" goto
if "%input%"=="2" exit

:Invalid1
cls
echo Your input is invalid, please
echo enter a valid entry.
pause>nul
goto Menu

There we go! Now let's get the name done. This time you don't need to add the input stuff, as no specific name is needed. We will be taking advantage of set /p. Type in "set /p Name=[Insert text here]". It's not like the name is useless, you can tell the game to use it! Now that we have a new section we should probably finish off the input command we put previously. There we go!

@echo off
TITLE Cupcake

:Menu
cls
echo Hello, welcome to the greatest cupcake of all time!
echo What would you like to do?
echo.
echo 1.Start
echo 2.Exit
echo.
echo Type "1" or "2" to do their respective uses
echo.
set /p input=Enter:
if "%input%"=="1" goto Name
if "%input%"=="2" exit

:Invalid1
cls
echo Your input is invalid, please
echo enter a valid entry.
pause>nul
goto Menu

:Name
cls
echo Hey there, what's your name?
echo.
set /p Name=Name:
goto Stuff

If we want the game to use what we put in as our name type in %Name%. Were gonna be coming to an end soon so let's just get the last few details done.

@echo off
TITLE Cupcake

:Menu
cls
echo Hello, welcome to the greatest cupcake of all time!
echo What would you like to do?
echo.
echo 1.Start
echo 2.Exit
echo.
echo Type "1" or "2" to do their respective uses
echo.
set /p input=Enter:
if "%input%"=="1" goto Name
if "%input%"=="2" exit

:Invalid1
cls
echo Your input is invalid, please
echo enter a valid entry.
pause>nul
goto Menu

:Name
cls
echo Hey there, what's your name?
echo.
set /p Name=Name:
goto Stuff

:Stuff
cls
echo Oh so it's %Name% eh?
echo that name sounds cool!
pause>nul
goto Loss

:Loss
cls
echo You lost the game.
echo You mean we didn't begin?
echo The whole goal of this game was not to tell me your name
echo (Not that you can skip it)
echo.
echo Try again?
echo.
echo Yes No
echo.
set /p input=Enter:
if "%input%"=="Yes" goto Menu
if "%input%"=="No" exit
if "%input%"=="yes" goto Menu
if "%input%"=="no" exit

:Invalid2
cls
echo Your input is invalid, please
echo enter a valid entry.
pause>nul
goto Loss


Finishing up




It's easy from here. Click save as, click all files, put .bat at the end of the files name, and then your finished. When you open it it will have a cmd interface and try typing in all the stuff you set it to do. If a black background with white text seems a little blank to you then create a shortcut of the file, then click properties of the shortcut there is a little vanity options for that. If you click the shortcut tab by clicking change Icon you can give it a premade icon or a custom icon (Icons must be a special file, just look up how to make an  icon) The rest should be pretty obvious and easy to figure out. If you want to play my game copy and paste the final code above into notepad and save it like mentioned above.

0 comments:

Post a Comment