How To Make A Video Game With CMD: 9 Steps (With Pictures)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

wikiHow to Make a Video Game With Cmd

Here is a free, easy, no-download way to make a video game. You will learn a little bit about
batch programming in the process. You'll need to supply your own story to go with this game.

Mumbai's Premium
BigStylist - Beauticians At Your
Doorstep. Pamper
Mumbai » Yourself Now!
bigstylist.com/Special_Offers

Steps

1 Anything in apostrophes can be changed, it won't affect the game - don't accidentally
type it in to the actual code.
Steps Community Q&A Tips Related wikiHows Reader Pictures
2 Open Notepad or any other coding programs-Geany, Notepad++, etcetera. Save the file
as ‘My Game’.bat

Steps Community Q&A Tips Related wikiHows Reader Pictures

3 Start the Code. Start by typing:

@echo off
title ‘My Game’
color 0A
if "%1" neq "" ( goto %1)
pause
4 Add Colours. Now save it and run, it will come up with an error and all the different
colour combinations. Find the one you like and type it in after “color”, instead of “zz”. A
good combination is color 0A, it makes the text green and the background black.

5 Create the Menu. To create the menu get rid of pause and type in:

:Menu
cls
echo ‘1. Start’
echo ‘2. Instructions’
echo ‘3. Exit’
set /p answer=‘Type the number of your option and press enter.’
if %answer%==1 goto ‘Start_1’
if %answer%==2 goto ‘Instructions’
if %answer%==3 goto ‘Exit’

6 Creating ‘Exit’ and ‘Instructions’. To create the exit screen type in this:

:‘Exit’
echo Thanks for playing !
exit /b
Now for the instructions type in:
 :‘Instructions’
cls
echo ‘Instructions’
echo.
Then write:
echo ‘Your instructions here’
As many times as you like then type:
pause
goto Menu
7 Begin the game. Type in a scenario:

:Start_1
cls
echo ‘You have run into bad guys. Their forces are:’
echo ‘3 farmers’
echo ‘You have a high chance of winning.’
set /p answer=‘Would you like to fight or run?’
if %answer%==‘Fight’ goto ‘Fight_1’
if %answer%==‘Run’ goto ‘Run_1’

8 Fighting and Running. Now to make fighting and running:


:Run_1
cls
echo You ran away safely !
pause
goto ‘Start_1’
:Fight_1
echo You have chosen to fight.
echo The battle is waging.
set /p answer= Type number 1 and press enter to continue:
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 Sorry, you lost the battle :(
pause
goto Menu
:‘Win_Fight_1’
cls
echo Congrats, you won the fight!
set /p answer=‘Would you like to save?’
if %answer%==‘Yes’ goto ‘Save’
if %answer%==‘No’ goto ‘Start_2’
:‘Save’
goto ‘Start_2’
Now you can repeat the code used in ‘Start_1’ to create a second fight and a third and
fourth and so on.
Also when you type e.g. :Fight_1 you also have to make sure that parts that say goto
Fight_1 stay the same as each other so if you change one you have to change both.
9 Just close the notepad, then click yes, save the file, change the format to all file,add .bat
after you type the name.

Advertisement

Community Q&A

Do I need to put a quote mark before and/or after echoing something?

Answered by wikiHow Contributor

No. After echoing, make a space and write what you want to display in a single line.

8 0

How do I start playing?

Answered by wikiHow Contributor


When you save the file as .bat, check where it is being saved. Change the location to your desktop
(so that it will be easy to find) and save it. Then double click on the .bat file and start playing.

12 7

How can I open a game?

Answered by wikiHow Contributor

Go on the desktop screen of your PC. There you will see a folder named as My Documents, where
you can see your game and can run it from there.

12 14

How can I learn how to code?

Answered by wikiHow Contributor

That depends what you want. C++ is for non-image based programs(they display in a cmd looking
window) adn C# is for image based programs like games. You should start with c++ tough, since c#
is more advanced. Google and download code blocks, an c++ code editor. You can find
documentation and lessons online.

8 9

What is a bat file, and where do I put it?

Answered by wikiHow Contributor

A bat file is a batch file, and it runs on cmd (command prompt). You can put it on your desktop to
make it easier to test your stuff. Show more answers

What's the full source code without font and 's?

Answer

I have tried every thing but the game is not working. Why is that?

Answer

It just closes when I'm pressing enter, what should I do?

Answer
How to play the game which we have made because we cannot play with text?

Answer

What might be causing my game to not work?

Answer

Show more unanswered questions

Ask a Question

Your question here

Submit

Tips

Remember, whenever you want something to be seen by the player, you have to type echo in
front of it.

Helpful?
 

Play your game along the way, even if you don't have the whole thing done. It will help you to
see how what you type corresponds with what you get and detect errors.

Helpful?
 

If you need to get out during the middle of a test run of your game, type Ctrl-C.

Helpful?
 

Batch files in Windows can be put to many uses automating tasks, but writing a text game
like this is a fun way to learn how they work.

Helpful?
 

Check your batch script carefully and you will notice the wrong thing.

Helpful?
 

Unable to launch is a very common error.


Helpful?
 

Know a good tip? Add it. Add

Related wikiHows

How to Make a Text Based Game

How to Use the Microsoft Batch File Language

How to Write a Batch File

How to Create Options or Choices in a Batch File

How to Draw With Text in Notepad


How to Make Computer Games

How to Make a Video Game from Scratch

How to Make a Flash Game

How to Theorize About Ordinary Time

How to Code a Video Game

Advertisement
Article Info

Sources and Attribution

Made Recently

1 year ago 2 years ago

2 years ago 2 years ago


Add a photo

Did this article help you?

Yes No

rprise Me
Su
!

wikiHow to...

You might also like