Instructables

How to make a simple Batch game (trivia!)

Step 3: Finalizing

@echo off
title The Trivia game
:Main
echo.
echo.
echo ------------------------------
echo Trivia Game
echo --------------------------------
echo.
echo.
echo ------------------
echo Type A and press ENTER to play
echo Type B and press ENTER to see instructions
echo ----------------------
set /p input=COMMAND?
if %input%==a goto Q1
if %input%==b goto instructions
goto error

Ok, back to the main menu. We will now add the extra labels that are required (error, instructions, wrong)

@echo off
title The Trivia game
:Main
echo.
echo.
echo ------------------------------
echo Trivia Game
echo --------------------------------
echo.
echo.
echo ------------------
echo Type A and press ENTER to play
echo Type B and press ENTER to see instructions
echo ----------------------
set /p input=COMMAND?
if %input%==a goto PLAY
if %input%==b goto instructions
goto error

:error
echo Dingbat! Thats an invalid command.
pause
goto Main

:instructions
echo Type instructions here
pause
goto Main

:wrong
echo Sorry, but...
echo YOU LOSE!!
pause
goto Main

:Q1
echo                                 ----------------------------------------
echo                                        What is a boat?
echo                                  ----------------------------------------
echo                                [a-A water vehichle] [b-A land vehicle]
echo                                          [c-A truck] [d-An animal]
set p/ input=ANSWER?
if %input%==a goto score1
if %input%==b goto wrong
if %input%==c goto wrong
if %input%==d goto wrong
goto error

:score 1
set a/ qdone=%qdone%+1
echo Congratz, you have completed %qdone% question(s)!
echo Press any button to go to the next question!
pause>nul
goto Q2

:Q2
(Put question here)

Okay, thats basically it. Now, this step is UBER IMPORTANT
save it as a BAT file, so say your game is called trivia save it as trivia.bat





That's basically it! Add more questions, and a winning screen, and your done!



 
Remove these adsRemove these ads by Signing Up
This is my code. It won't work, for some reason.
Please reply.
Sorry bout the spacing

@echo off
title The Trivia game
:Main
echo.
echo.
echo ------------------------------
echo Trivia Game
echo --------------------------------
echo.
echo.
echo ------------------
echo Type A and press ENTER to play
echo Type B and press ENTER to see instructions
echo ----------------------
set /p input=COMMAND?
if %input%==a goto start
if %input%==b goto instructions
goto error

:error
echo Dingbat! Thats an invalid command.
pause
goto Main

:instructions
echo This is a trivia game. Just do what you think you need to do.
pause
goto Main

:wrong
echo Sorry, but...
echo YOU LOSE!!
echo Now start over. You deserve another chance!
pause
goto Main

:start
echo ----------------------------------------
echo What is a boat?
echo ----------------------------------------
echo [a-A water vehichle] [b-A land vehicle]
echo [c-A truck] [d-An animal]
set p/ input=ANSWER?
if %input%==a goto score1
if %input%==b goto wrong
if %input%==c goto wrong
if %input%==d goto wrong
goto error

:score 1
set a/ qdone=%qdone%+1
echo Congratz, you have completed %qdone% question(s)!
echo Press any button to go to the next question!
pause>nul
goto Q2

:Q2
echo --------------------------------
echo What is a duck?
echo --------------------------------
echo [a- THE BEST ANIMAL EVAR] [b- An ordinary animal]
echo [c- A vegetable] [d-Something random]
set p/ input=ANSWER?
if %input%==a goto score2
if %input%==b goto wrong
if %input%==c goto wrong
if %input%==d goto wrong
goto error

:score 2
set a/ qdone=%qdone%+2
echo Congratz, you have completed %qdone% question(s)!
echo Press any button to go to the next question!
pause>nul
goto Q3

:Q3
echo ----------------------------------
echo How do you make a cake?
echo -----------------------------------
echo [a-Using the power of your MIND]
echo [b- Using a recipe]
echo [c- Go buy it] [d- Get your friends to make it for you]
set p/ input=ANSWER?
if %input%==a goto wrong
if %input%==b goto score3
if %input%==c goto wrong
if %input%==d goto wrong
goto error

:score 3
set a/ qdone=%qdone%+3
echo Congratz, you have completed %qdone% question(s)!
echo Press any button to go to the next question!
pause>nul
goto Q4

:Q4
echo ------------------------------------
echo 5 cubed= ?
echo ----------------------------------
echo [a-15] [b-125] [c-250] [d-500]
set p/ input=ANSWER?
if %input%==a goto wrong
if %input%==b goto score4
if %input%==c goto wrong
if %input%==d goto wrong
goto error

:score 3
set a/ qdone=%qdone%+4
echo Congratz, you have completed %qdone% question(s)!
echo Press any button to go to the next question!
pause>nul
goto Q5

:Q5
echo --------------------------------------------
echo What file format does this game use?
echo --------------------------------------------
echo [a- .cmd] [b- .exe] [c- I don't even know] [d- .bat]
set p/ input=ANSWER?
if %input%==a goto wrong
if %input%==b goto wrong
if %input%==c goto wrong
if %input%==d goto winner
goto error

:winner
echo Great job! You beat the trivia game!
echo If you'd like, email this to your friends!
echo Be sure to inform them that it can only be used on Windows PC's.
echo Thanks for playing!!!!
pause
I tried all of the trivia batch files on this page and none of them worked, so I came up with my own. I tested it out like a million times so I know it works.
Save as a batch file (.bat).

color a4
@echo off
title Trivia game
:Main
set /p choice=Type A and press ENTER to play. Type B and press ENTER for instructions. Type C and press ENTER for credits.
if %choice%==a goto start
if %choice%==b goto instructions
if %choice%==c goto credits

:instructions
echo Instructions: Type the letter of the answer you think is correct.
goto main

:credits
echo Credits: This game was made by JAYFIN programing
goto main

:start
@echo off
set /p choice=What food group has the highest levels of proteint? 1: Bread, 2:Vegetables, 3:Meat, 4:Fruit
if %choice%==1 goto wrong
if %choice%==2 goto wrong
if %choice%==3 goto correct
if %choice%==4 goto wrong
echo That answer is unacceptable. Try again.
goto start

:wrong
echo Wrong answer try again.
goto start

:correct
echo Answer correct.
goto Q2

:Q2
@echo off
set /p choice=Who said: "I'm the president of the United States and I'm not going to eat any more broccoli"? 1:George H. W. Bush, 2:Bill Clinton, 3:Barak Obama, 4:Ronald Reagan.
if %choice%==1 goto correct q2
if %choice%==2 goto wrong q2
if %choice%==3 goto wrong q2
if %choice%==4 goto wrong q2
echo That answer is unacceptable. Try again.
goto Q2

:wrong q2
echo Wrong answer try again.
goto Q2

:correct q2
echo Answer correct.
goto Q3

:Q3
@echo off
set /p choice=In Peter Pan, what sort of creature was Nana? 1:Dog, 2:Human, 3:Firefly, 4:Fairy.
if %choice%==1 goto correct q3
if %choice%==2 goto wrong q3
if %choice%==3 goto wrong q3
if %choice%==4 goto wrong q3
echo That answer is unacceptable. Try again.
goto Q3

:wrong q3
echo Wrong answer try again.
goto Q3

:correct q3
echo Answer correct.
goto Q4

:Q4
@echo off
set /p choice=What's the name of the bird that Sylvester (from loony tunes) chases in vain? 1:Cupcake, 2:Tweety Pie, 3:Jerry, 4:Eli.
if %choice%==1 goto wrong q4
if %choice%==2 goto correct q4
if %choice%==3 goto wrong q4
if %choice%==4 goto wrong q4
echo That answer is unacceptable. Try again.
goto Q4

:wrong q4
echo Wrong answer try again.
goto Q4

:correct q4
echo Answer is correct.
goto Q5

:Q5
@echo off
set /p choice=Where was the second Atom bomb dropped? 1:Tokyo, 2:Osaka, 3:Hiroshima, 4:Nagasaki.
if %choice%==1 goto wrong q5
if %choice%==2 goto wrong q5
if %choice%==3 goto wrong q5
if %choice%==4 goto correct q5
echo That answer is unacceptable. Try again.
goto Q5

:wrong q5
echo Wrong answer try again.
goto Q5

:correct q5
echo Congratulations! You have completed this quiz.
echo JAYFIN Programing
goto Main
It didnt work >:(
Mistersalt (author)  TheExplodingTacoz2 years ago
sorry it didn't work. Perhaps review your code?
Mistersalt (author) 4 years ago
People, plz rate nicely as this is MY FIRST instructable. Thanks!
you have made batch awesome but do you think you could add a download
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!