loading

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!



<p>Why does this not work?</p><p>@echo off</p><p>echo what is your name?</p><p>set /p name=</p><p>echo Hello %name%</p><p>goto level1</p><p>:level1</p><p>echo elsa a boy</p><p>echo A) True</p><p>echo B) False</p><p>if %select% == goto wrong</p><p>if %select% == goto bye bye</p><p>:worong</p><p>you were wrong! sorry!</p><p>pause </p><p>exit</p><p>:bye bye</p><p>echo goodbye you were right!</p><p>pause</p><p>exit</p>
<p>The reason why it wont work is because 1. wrong is misspelled 12th line on the code (technically 13 because of your comment but since were talking about the code 12th line.) And also </p><p>if %select% == goto wrong</p><p>if %select% == goto bye bye</p><p>this code is wrong it should be </p><p>if %select% == A goto wrong</p><p>if %select% == B goto bye bye</p><p>And to avoid people cheating I would put this command in after it 'Goto Cheater' this is to prevent people from typing random things and they get it right. I hope I helped you.</p>
<p>You can actually do</p><p>:FamilyGuyQuestion1</p><p>cls</p><p>Title Family Guy</p><p>echo.</p><p>echo Who is the main character in Family Guy?</p><p>echo.</p><p>echo Peter</p><p>echo.</p><p>echo Glenn</p><p>echo.</p><p>echo Joe</p><p>echo.</p><p>set /p familyguy1=Enter:</p><p>if %familyguy1% equ Peter goto CorrectFG1</p><p>if %familyguy1% equ Glenn goto IncorrectFG1</p><p>if %familyguy1% equ Joe goto IncorrectFG1</p><p>goto FamilyGuyQuestion1</p><p>Something Like this instead of using numbers for answers, works for menus too</p>
<p>hope it works for you guys :D</p>
<p>well i made my own one.. but its sure a good one..</p><p>@echo off</p><p>title Cooler Reyes Mini Game</p><p>echo Welcome :D</p><p>pause</p><p>echo Would you like me to start the game? (y/n)</p><p>set /p c=</p><p>if %c%==y goto menu32</p><p>if %c%==n exit</p><p>:menu32</p><p>cls</p><p>echo Hi! im Dexter, how about you?</p><p>set /p name=</p><p>cls</p><p>echo Nice to meet you %name%!</p><p>pause</p><p>cls</p><p>echo What minigame do you want to play %name%?</p><p>echo Math or Bignumber?</p><p>set /p select=</p><p>if %select%==Math goto mathquiz</p><p>if %select%==Bignumber goto number</p><p>:mathquiz</p><p>cls</p><p>echo You have chosen math %name%!</p><p>pause</p><p>echo Now you'll suffer!</p><p>pause</p><p>cls</p><p>echo ok, first one :D</p><p>pause</p><p>echo 365+546?</p><p>echo 1. 779</p><p>echo 2. 911</p><p>echo 3. 690</p><p>set /p choice1=</p><p>if %choice1%==1 goto lose1</p><p>if %choice1%==2 echo You got me!</p><p>if %choice1%==3 goto lose1</p><p>pause</p><p>cls</p><p>echo now, more difficult XD</p><p>pause</p><p>echo 650+765?</p><p>echo 1. 1334</p><p>echo 2. 1565</p><p>echo 3. 1415</p><p>set /p choice2=</p><p>if %choice2%==1 goto lose2</p><p>if %choice2%==2 goto lose2</p><p>if %choice2%==3 echo wooooow!</p><p>pause</p><p>cls</p><p>echo your really good at this %name%!</p><p>pause</p><p>echo but not this time!</p><p>pause</p><p>echo 924+876?</p><p>echo 1. 2000</p><p>echo 2. 1900</p><p>echo 3. 1800</p><p>set /p choice3=</p><p>if %choice3%==1 echo You won the game!! congrats %name% :D</p><p>if %choice3%==2 goto lose3</p><p>if %choice3%==3 goto lose3</p><p>cls</p><p>:lose1</p><p>cls</p><p>echo haha, you lose :D</p><p>pause</p><p>echo try again? (y/n)</p><p>set /p kj=</p><p>if %kj%==y goto mathquiz</p><p>if %kj%==n exit</p><p>cls</p><p>:lose2 </p><p>cls</p><p>echo haha, you lose :D</p><p>pause</p><p>echo try again? (y/n)</p><p>set /p kj=</p><p>if %kj%==y goto mathquiz</p><p>if %kj%==n exit</p><p>cls</p><p>:lose3</p><p>cls</p><p>echo haha, you lose :D</p><p>pause</p><p>echo try again? (y/n)</p><p>set /p kj=</p><p>if %kj%==y goto mathquiz</p><p>if %kj%==n exit</p><p>cls</p><p>:number1</p><p>cls</p><p>echo ok lets play the thing you selected %name%! Big number!!!</p><p>pause</p><p>echo type set to go to settings</p><p>set /p sets=</p><p>if %sets%==set goto settings</p><p>echo choose a number 1-10</p><p>set /p cnumber=</p><p>if %cnumber%==1 echo i choose 2! I Win! Play Again? (y/n)</p><p>set /p yorno=</p><p>if %cnumber%==2 echo i choose 3! I Win! Play Again? (y/n)</p><p>if %cnumber%==3 echo i choose 4! I Win! Play Again? (y/n)</p><p>if %cnumber%==4 echo i choose 5! I Win! Play Again? (y/n)</p><p>if %cnumber%==5 echo i choose 6! I Win! Play Again? (y/n)</p><p>if %cnumber%==6 echo i choose 7! I Win! Play Again? (y/n)</p><p>if %cnumber%==7 echo i choose 8! I Win! Play Again? (y/n)</p><p>if %cnumber%==8 echo i choose 9! I Win! Play Again? (y/n)</p><p>if %cnumber%==9 echo i choose 10! I Win! Play Again? (y/n)</p><p>if %cnumber%==10 echo i choose 10! Tie! Play Again? (y/n)</p><p>if %yorno%==y goto number</p><p>if %yorno%==n exit</p><p>cls</p><p>:settings</p><p>cls</p><p>echo CHOOSE :D</p><p>pause</p><p>echo 1. I want me to always win</p><p>echo 2. I want me to always lose</p><p>set /p sets1=</p><p>if %sets1%==1 goto number2</p><p>if %sets1%==2 goto number1</p><p>cls</p><p>:number 2</p><p>cls</p><p>echo ok lets play the thing you selected %name%! Big number!!!</p><p>pause</p><p>echo type set to go to settings</p><p>set /p sets=</p><p>if %sets%==set goto settings</p><p>echo choose a number 1-10</p><p>set /p cnumber=</p><p>if %cnumber2%==1 echo i choose 1! Tie! Play Again? (y/n)</p><p>set /p yorno2=</p><p>if %cnumber2%==2 echo i choose 1! You Win! Play Again? (y/n)</p><p>if %cnumber2%==3 echo i choose 2! You Win! Play Again? (y/n)</p><p>if %cnumber2%==4 echo i choose 3! You Win! Play Again? (y/n)</p><p>if %cnumber2%==5 echo i choose 4! You Win! Play Again? (y/n)</p><p>if %cnumber2%==6 echo i choose 5! You Win! Play Again? (y/n)</p><p>if %cnumber2%==7 echo i choose 6! You Win! Play Again? (y/n)</p><p>if %cnumber2%==8 echo i choose 7! You win! Play Again? (y/n)</p><p>if %cnumber2%==9 echo i choose 8! You win! Play Again? (y/n)</p><p>if %cnumber2%==10 echo i choose 9! You win! Play Again? (y/n)</p><p>if %yorno2%==y goto number</p><p>if %yorno2%==n exit</p>
This is my code. It won't work, for some reason.<br>Please reply.<br>Sorry bout the spacing<br><br>@echo off<br>title The Trivia game<br>:Main<br>echo.<br>echo.<br>echo ------------------------------<br>echo Trivia Game<br>echo --------------------------------<br>echo.<br>echo.<br>echo ------------------<br>echo Type A and press ENTER to play<br>echo Type B and press ENTER to see instructions<br>echo ----------------------<br>set /p input=COMMAND?<br>if %input%==a goto start<br>if %input%==b goto instructions<br>goto error<br><br>:error<br>echo Dingbat! Thats an invalid command.<br>pause<br>goto Main<br><br>:instructions<br>echo This is a trivia game. Just do what you think you need to do.<br>pause<br>goto Main<br><br>:wrong<br>echo Sorry, but...<br>echo YOU LOSE!!<br>echo Now start over. You deserve another chance!<br>pause<br>goto Main<br><br>:start<br>echo ----------------------------------------<br>echo What is a boat?<br>echo ----------------------------------------<br>echo [a-A water vehichle] [b-A land vehicle]<br>echo [c-A truck] [d-An animal]<br>set p/ input=ANSWER?<br>if %input%==a goto score1<br>if %input%==b goto wrong<br>if %input%==c goto wrong<br>if %input%==d goto wrong<br>goto error<br><br>:score 1<br>set a/ qdone=%qdone%+1<br>echo Congratz, you have completed %qdone% question(s)!<br>echo Press any button to go to the next question!<br>pause&gt;nul<br>goto Q2<br><br>:Q2<br>echo --------------------------------<br>echo What is a duck?<br>echo --------------------------------<br>echo [a- THE BEST ANIMAL EVAR] [b- An ordinary animal]<br>echo [c- A vegetable] [d-Something random]<br>set p/ input=ANSWER?<br>if %input%==a goto score2<br>if %input%==b goto wrong<br>if %input%==c goto wrong<br>if %input%==d goto wrong<br>goto error<br><br>:score 2<br>set a/ qdone=%qdone%+2<br>echo Congratz, you have completed %qdone% question(s)!<br>echo Press any button to go to the next question!<br>pause&gt;nul<br>goto Q3<br><br>:Q3<br>echo ----------------------------------<br>echo How do you make a cake?<br>echo -----------------------------------<br>echo [a-Using the power of your MIND]<br>echo [b- Using a recipe]<br>echo [c- Go buy it] [d- Get your friends to make it for you]<br>set p/ input=ANSWER?<br>if %input%==a goto wrong<br>if %input%==b goto score3<br>if %input%==c goto wrong<br>if %input%==d goto wrong<br>goto error<br><br>:score 3<br>set a/ qdone=%qdone%+3<br>echo Congratz, you have completed %qdone% question(s)!<br>echo Press any button to go to the next question!<br>pause&gt;nul<br>goto Q4<br><br>:Q4<br>echo ------------------------------------<br>echo 5 cubed= ?<br>echo ----------------------------------<br>echo [a-15] [b-125] [c-250] [d-500]<br>set p/ input=ANSWER?<br>if %input%==a goto wrong<br>if %input%==b goto score4<br>if %input%==c goto wrong<br>if %input%==d goto wrong<br>goto error<br><br>:score 3<br>set a/ qdone=%qdone%+4<br>echo Congratz, you have completed %qdone% question(s)!<br>echo Press any button to go to the next question!<br>pause&gt;nul<br>goto Q5<br><br>:Q5<br>echo --------------------------------------------<br>echo What file format does this game use?<br>echo --------------------------------------------<br>echo [a- .cmd] [b- .exe] [c- I don't even know] [d- .bat]<br>set p/ input=ANSWER?<br>if %input%==a goto wrong<br>if %input%==b goto wrong<br>if %input%==c goto wrong<br>if %input%==d goto winner<br>goto error<br><br>:winner<br>echo Great job! You beat the trivia game!<br>echo If you'd like, email this to your friends!<br>echo Be sure to inform them that it can only be used on Windows PC's.<br>echo Thanks for playing!!!!<br>pause<br>
There are some errors in the coding <br> <br>I fixed them and this is the new one: <br> <br>@echo off <br>title The Trivia game <br>:Main <br>echo. <br>echo. <br>echo ------------------------------ <br>echo Trivia Game <br>echo -------------------------------- <br>echo. <br>echo. <br>echo ------------------ <br>echo Type A and press ENTER to play <br>echo Type B and press ENTER to see instructions <br>echo ---------------------- <br>set /p input= <br>if %input%==a goto start <br>if %input%==b goto instructions <br>if %inpu%==A goto start <br>if %input%--B goto instructions <br>goto error <br> <br>:error <br>echo Dingbat! Thats an invalid command. <br>pause <br>goto Main <br> <br>:instructions <br>echo This is a trivia game. Just do what you think you need to do. <br>pause <br>goto Main <br> <br>:wrong <br>echo Sorry, but... <br>echo YOU LOSE!! <br>echo Now start over. You deserve another chance! <br>pause <br>goto Main <br> <br>:start <br>echo ---------------------------------------- <br>echo What is a boat? <br>echo ---------------------------------------- <br>echo [a-A water vehichle] [b-A land vehicle] <br>echo [c-A truck] [d-An animal] <br>set p/ input=ANSWER? <br>if %input%==a goto score1 <br>if %input%==b goto wrong <br>if %input%==c goto wrong <br>if %input%==d goto wrong <br>goto error <br> <br>:score 1 <br>set a/ qdone=%qdone%+1 <br>echo Congratz, you have completed %qdone% question(s)! <br>echo Press any button to go to the next question! <br>pause&gt;nul <br>goto Q2 <br> <br>:Q2 <br>echo -------------------------------- <br>echo What is a duck? <br>echo -------------------------------- <br>echo [a- THE BEST ANIMAL EVAR] [b- An ordinary animal] <br>echo [c- A vegetable] [d-Something random] <br>set p/ input=ANSWER? <br>if %input%==a goto score2 <br>if %input%==b goto wrong <br>if %input%==c goto wrong <br>if %input%==d goto wrong <br>goto error <br> <br>:score 2 <br>set a/ qdone=%qdone%+2 <br>echo Congratz, you have completed %qdone% question(s)! <br>echo Press any button to go to the next question! <br>pause&gt;nul <br>goto Q3 <br> <br>:Q3 <br>echo ---------------------------------- <br>echo How do you make a cake? <br>echo ----------------------------------- <br>echo [a-Using the power of your MIND] <br>echo [b- Using a recipe] <br>echo [c- Go buy it] [d- Get your friends to make it for you] <br>set p/ input=ANSWER? <br>if %input%==a goto wrong <br>if %input%==b goto score3 <br>if %input%==c goto wrong <br>if %input%==d goto wrong <br>goto error <br> <br>:score 3 <br>set a/ qdone=%qdone%+3 <br>echo Congratz, you have completed %qdone% question(s)! <br>echo Press any button to go to the next question! <br>pause&gt;nul <br>goto Q4 <br> <br>:Q4 <br>echo ------------------------------------ <br>echo 5 cubed= ? <br>echo ---------------------------------- <br>echo [a-15] [b-125] [c-250] [d-500] <br>set p/ input=ANSWER? <br>if %input%==a goto wrong <br>if %input%==b goto score4 <br>if %input%==c goto wrong <br>if %input%==d goto wrong <br>goto error <br> <br>:score 3 <br>set a/ qdone=%qdone%+4 <br>echo Congratz, you have completed %qdone% question(s)! <br>echo Press any button to go to the next question! <br>pause&gt;nul <br>goto Q5 <br> <br>:Q5 <br>echo -------------------------------------------- <br>echo What file format does this game use? <br>echo -------------------------------------------- <br>echo [a- .cmd] [b- .exe] [c- I don't even know] [d- .bat] <br>set p/ input=ANSWER? <br>if %input%==a goto wrong <br>if %input%==b goto wrong <br>if %input%==c goto wrong <br>if %input%==d goto winner <br>goto error <br> <br>:winner <br>echo Great job! You beat the trivia game! <br>echo If you'd like, email this to your friends! <br>echo Be sure to inform them that it can only be used on Windows PC's. <br>echo Thanks for playing!!!! <br>pause <br> <br> <br> <br> <br>
By Q4 you wrote: set p/ input, That will NOT work you have to make it: set /p input. <br>Make the / before the p! <br>
Sorry, merely a mistype.
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. <br>Save as a batch file (.bat). <br> <br>color a4 <br>@echo off <br>title Trivia game <br>:Main <br>set /p choice=Type A and press ENTER to play. Type B and press ENTER for instructions. Type C and press ENTER for credits. <br>if %choice%==a goto start <br>if %choice%==b goto instructions <br>if %choice%==c goto credits <br> <br>:instructions <br>echo Instructions: Type the letter of the answer you think is correct. <br>goto main <br> <br>:credits <br>echo Credits: This game was made by JAYFIN programing <br>goto main <br> <br>:start <br>@echo off <br>set /p choice=What food group has the highest levels of proteint? 1: Bread, 2:Vegetables, 3:Meat, 4:Fruit <br>if %choice%==1 goto wrong <br>if %choice%==2 goto wrong <br>if %choice%==3 goto correct <br>if %choice%==4 goto wrong <br>echo That answer is unacceptable. Try again. <br>goto start <br> <br>:wrong <br>echo Wrong answer try again. <br>goto start <br> <br>:correct <br>echo Answer correct. <br>goto Q2 <br> <br>:Q2 <br>@echo off <br>set /p choice=Who said: &quot;I'm the president of the United States and I'm not going to eat any more broccoli&quot;? 1:George H. W. Bush, 2:Bill Clinton, 3:Barak Obama, 4:Ronald Reagan. <br>if %choice%==1 goto correct q2 <br>if %choice%==2 goto wrong q2 <br>if %choice%==3 goto wrong q2 <br>if %choice%==4 goto wrong q2 <br>echo That answer is unacceptable. Try again. <br>goto Q2 <br> <br>:wrong q2 <br>echo Wrong answer try again. <br>goto Q2 <br> <br>:correct q2 <br>echo Answer correct. <br>goto Q3 <br> <br>:Q3 <br>@echo off <br>set /p choice=In Peter Pan, what sort of creature was Nana? 1:Dog, 2:Human, 3:Firefly, 4:Fairy. <br>if %choice%==1 goto correct q3 <br>if %choice%==2 goto wrong q3 <br>if %choice%==3 goto wrong q3 <br>if %choice%==4 goto wrong q3 <br>echo That answer is unacceptable. Try again. <br>goto Q3 <br> <br>:wrong q3 <br>echo Wrong answer try again. <br>goto Q3 <br> <br>:correct q3 <br>echo Answer correct. <br>goto Q4 <br> <br>:Q4 <br>@echo off <br>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. <br>if %choice%==1 goto wrong q4 <br>if %choice%==2 goto correct q4 <br>if %choice%==3 goto wrong q4 <br>if %choice%==4 goto wrong q4 <br>echo That answer is unacceptable. Try again. <br>goto Q4 <br> <br>:wrong q4 <br>echo Wrong answer try again. <br>goto Q4 <br> <br>:correct q4 <br>echo Answer is correct. <br>goto Q5 <br> <br>:Q5 <br>@echo off <br>set /p choice=Where was the second Atom bomb dropped? 1:Tokyo, 2:Osaka, 3:Hiroshima, 4:Nagasaki. <br>if %choice%==1 goto wrong q5 <br>if %choice%==2 goto wrong q5 <br>if %choice%==3 goto wrong q5 <br>if %choice%==4 goto correct q5 <br>echo That answer is unacceptable. Try again. <br>goto Q5 <br> <br>:wrong q5 <br>echo Wrong answer try again. <br>goto Q5 <br> <br>:correct q5 <br>echo Congratulations! You have completed this quiz. <br>echo JAYFIN Programing <br>goto Main <br>
It didnt work &gt;:(
Did you at the places for the code to got<br><br>Ex:<br>@echo off<br>:start<br>echo enter a number<br>set /p num=(1-3)<br>if %num% == 1 goto num1<br>if %num% == 2 goto num2<br>if %num% == 3 goto num3<br>:num1<br>echo you entered the number1<br>pause<br>goto start<br>:num2<br>echo you entered the number2<br>pause<br>goto start<br>:num2<br>echo you entered the number2<br>pause<br>goto start<br>
sorry it didn't work. Perhaps review your code?
I'm currently making a trivia game with passwords and a help menu.
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 <br>
You got a/ backwards.<br>I tried /a, and that worked instead of a/<br>so I think you got that backwards
I'm trying to get this to work, when you have the command &quot;if %input%==a goto PLAY&quot; where is play? It just closes my window...
Oh sorry, i must have forgot to put that in. Well, you can create a :play label otherwise you can just change the script so that...<br><br>if %input%==a goto Q1<br><br>By the way, if there is a label that does not exist in the script, then it just closes it<br><br>Woops XD
Thanks man, i kept doing this and was like WTF it just closes this helps a lot!
No problamo! I'm here to help if you need any other assistance.

About This Instructable

13,715views

7favorites

License:

More by Mistersalt:How to make a simple Batch game (trivia!) 
Add instructable to: