Introduction: Making a Text Based Adventure

About: I enjoy starting many different projects from programming to electronics. I also enjoy games like dungeons and dragons and Warhammer. I love retro games including Tetris and street fighter 2.

Have you ever wanted to create your own text based game for free with no hassle. Well this is for you. All you are going to need is a creative idea and a computer. So lets get started?

Step 1: The Code You Will Be Using

So to start with you are going to need to learn some batch code. It is very alike php so if you know some of that this will be very easy to follow. Also it is a language in which is quite fast to do. Here are some of the basic scripts.

@echo off -You should always start with this otherwise after every part of the code it will show the full location so it is unreadable.

@title [ ] -Basically the name that you will see in the bar of the file so just fill in the brackets with the name of your game.

:example -These are different parts of your codes which are important for when people are deciding where to go they are directed to the different parts. You must call them all different and you can call them whatever you like.

cls -This clears the current writing on the screen so you should put it after most of the different parts.

echo -Anything after this will be displayed on screen for example- echo Hello world! will show Hello world!

pause -This is needed for people to be able to read what it says otherwise it will go instantly unless afterwards you need to put an input in.

set /a example= -Set /a is setting or creating an arithmetic variable so a number. This will be used to set a variable as a number for example what their score is. Then you can set it to any number or if you keep it blank so it will be set by the user.

set /p example= -This is for making a string variable so setting a variable as a word. This can be used for people to write where they want to go or you can just use it and put a word at the end. Then you can set it to any word or keep it blank so it will be set by the user.

set /a example=%example%+1 -This is setting the variable as its self plus a number so if before hand it was 3 it would now be 4. This is useful for setting scores ect.

if %example% equ example goto :example -This can be put after the user input so once they have wrote where they want to go if they have wrote it correctly it will go to a certain part of the code. The first "example" is the variable and you need to use the same one as before, the next bit "equ example" shows that if it equals whatever you decide it to be the "goto" will it make it go to that part of the code for example :start. So if there several different decisions the user can do just repeat this but change the last two "example".

if %example% neq example goto :example -This is the opposite of he other one and you put it at the end of the others so this one is if it does not equal that it will go to a certain place. So you could use it if they put the wrong thing in it will go back to the start of the section ect.

%example% -If you put this in a text it will give the number or string assigned with it. For example "echo Your score is- %example%" and lets say if it was 2 it would show Your score is 2.

exit -You place this anywhere for example after goto to exit the application at that point.

goto -You can also just do goto on its own to go to a certain section of the code at that point.

If the section you want it to go to next is just under the one you are doing, you don't need to add goto.

Next step will show you part of a project so you can get to grips with what to do if you are unsure. It will use the code shown here.

Step 2: Example Game

@echo off

@title [game]

:start

echo Hello there welcome to dungeon adventurer.

echo What is your name?

set /p name=

:welcome

cls

echo Welcome %name%

pause

:firstchoice

cls

echo You enter through the door as you go forward there is a door to your left. Would you like to go left or

echo continue forward? left or forward?

set /p leftorforward1=

if %leftorforward1% equ left goto left1

if %leftorforward1% equ forward goto forward1

if %leftorforward1% neq left goto firstchoice

:left1

cls

echo You enter the room and find a bag of coins

pause

echo You leave the room and go forward.

:forward1

cls

echo You go forward and stood there is a small gobin. Would you like to aim for his head or his body? head or echo body?

set /p goblin=

if %leftorforward1 equ head goto death

if %leftorforward1 equ body goto kill1

if %leftorforward1 neq head goto forward1

:death

cls

echo The goblin ducks from your attack and stabs you in the neck.

echo You have died.

echo Your score is %score%

pause

exit

:kill1

cls

echo You stabbed it right in the heart and killed it.

pause

:win

cls

echo You have won this game your score is %score%

pause

exit

Step 3: Tips for Creating Your Game

Here are just a few tips for making your game.

1. After saying for example "would you like to continue forward or go left." afterwards I would put "forward or left" so they know what they have to write. Or to make it easier it could be done with numbers 1,2,3 ect.

2. Make sure it is easy to understand and fun!

3. You could add check points if it is a long game.

4. Keep the story simple to start with and make it more complex later on.

5. Make it so it is not so easy to remember where to go.

Step 4: Saving and Sharing Your Game

When you save it to play save it as a .bat file so for example when you press save and name it put something like game.bat.

But you cannot email it like this type of file so you have to change it to a text document and then ask them to go into notepad and save it with .bat at the end.

Thank you for reading through my tutorial and I hoped you enjoy!

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016

Hack Your Day Contest

Participated in the
Hack Your Day Contest