Batch programming :- How we Create a simple game in batch programming


Batch file programming


Batch File :-


In DOS, OS/2, and also Microsoft Windows, batch file is the name given to a

type of script file, a text file containing a series of commands to be executed by

the command interpreter.A batch file may contain any command the interpreter

accepts interactively at the command prompt.A batch file may also have

constructs( IF,GOTO, Labels, CALL, etc.) that enable conditional

branching and looping within the batch file.


Here is the source code of the creating a simple game in batch programming.

Text Editor :- Notepad

Save as :- .bat file

Created By :- Deepak Gupta
                     http://www.i-world-tech.blogspot.in/



@echo off
color A4
:menu
cls
echo Welcome to the My First Batch programming Game........!!!
echo [1]. Start
echo [2]. How To Play
echo Designed By :-
echo Deepak Gupta
echo http://www.i-world-tech.blogspot.in/
set /p number=

if %number% ==1 goto startgame
if %number% ==2 goto help
if %number% ==3 goto exit

:startgame
cls
echo Enter Your Name:
set /p name=
echo Hello %name%..!
echo %name%...Do You Want To Start The Quiz' Game ?(y/n)
set /p start=
if %start% == y goto level1
if %start% == n goto menu
goto startgame

:help
cls
echo [1]. Choose your correct answer
echo [2]. Press the Corresponding number of the answer
echo [3]. Then Hit Enter.
echo [4]. Go back ? (y/n)
set /p menugoto=
if %menugoto% == y goto menu
if %menugoto% == n goto exit
goto help


:level1
cls
echo %name%..Let's start Now....
echo level-1
echo Who is the founder of Google ?
echo [1]. Mark Zuckerberg
echo [2]. Lerry Page
echo [3]. Charles Babbage
echo [4]. Alan Turing
set /p answer1=
if %answer1% == 1 goto wrong1
if %answer1% == 2 goto correct1
if %answer1% == 3 goto wrong1
if %answer1% == 4 goto wrong1
goto level1

:correct1
echo Congrtz's %name%..
echo your Answer is right..!
echo So you want to go to next Level-2 ? (y/n)
set /p nl1=

if %nl1% == y goto level2
if %nl1% == n goto menu
goto correct1

:wrong1
echo sorry %name%..
echo your answer is wrong..
echo Want to Retry ?(y/n)
set /p wa1=
if %wa1% == y goto level1
if %wa1% == n goto menu
goto wrong1

:level2
cls
echo Level-2
echo Which one is the current version of Html...?
echo [1] Html 2
echo [2] Html 3
echo [3] Html 4
echo [4] Html 5
set /p aa=
if %aa% ==1 goto wrong2
if %aa% ==2 goto wrong2
if %aa% ==3 goto wrong2
if %aa% ==4 goto correct2
goto level2

:correct2
echo Congrtz's %name%..
echo your Answer is right..!
echo So you want to go to next Level-3 ? (y/n)
set /p nl2=

if %nl2% == y goto level3
if %nl2% == n goto menu
goto correct2

:wrong2
echo sorry %name%..
echo your answer is wrong...
echo want to Retry ? (y/n)
set /p wa2=
if %wa2% == y goto level2
if %wa2% == n goto menu
goto wrong2

:level3
cls
echo level-3
echo Where is the Microsoft headquarters located...?
echo [1]. Londan
echo [2]. New York
echo [3]. Virginia
echo [4]. Washington
set /p aa=
if %aa% ==1 goto wrong3
if %aa% ==2 goto wrong3
if %aa% ==3 goto wrong3
if %aa% ==4 goto correct3
goto level3

:correct3
echo Congrtz's ..%name%..
echo your Answer is right..!
echo So you want to go to next Level-4 ? (y/n)
set /p nl3=

if %nl3% == y goto level4
if %nl3% == n goto menu
goto correct3

:wrong3
echo sorry %name%..
echo your answer is wrong.
echo want to retry ?(y/n)
set /p wa3=
if %wa3% == y goto level3
if %wa3% == n goto menu
goto wrong3

:level4
cls
echo level-4
echo Which is the Largest States of India in terms of Area...?
echo [1]. Uttar Pradesh
echo [2]. Madhya Pradesh
echo [3]. Rajasthan
echo [4]. Gujarat
set /p aa=
if %aa% ==1 goto wrong4
if %aa% ==2 goto wrong4
if %aa% ==3 goto correct4
if %aa% ==4 goto wrong4
goto level4

:correct4
echo Congrtz's..%name%..
echo your answer is right..!
echo So you Want To go To Next Level-5 ? (y/n)
set /p nl4=

if %nl4% == y goto level5
if %nl4% == n goto menu
goto correct5

:wrong4
echo sorry %name%..
echo your Answer Is wrong.
echo Want to Retry ?(y/n)
set /p wa4=
if %wa4% == y goto level4
if %wa4% == n goto menu
goto wrong4


:level5
cls
echo level-5
echo Who is on the 100 doller bill coins...?
echo [1]. Jeff Dunham
echo [2]. Ben Franklin
echo [3]. Thomas Train
echo [4]. Tommy King
set /p aa=
if %aa% ==1 goto wrong5
if %aa% ==2 goto correct5
if %aa% ==3 goto wrong5
if %aa% ==4 goto wrong5
goto level5

:correct5
cls
echo congtz's....%name%..
echo You Win The Game....!!!!!!!
echo Designed By:-
echo Deepak Gupta
echo i-World-Tech.blogspot.in
goto correct5

:wrong5
cls
echo sorry....%name%..
echo you lost ..!
echo retry game?(y/n)
set /p retry=
if %retry% == y goto level5
if %retry% == n goto exit

Thank You To All My Reader
Deepak Gupta
www.i-world-tech.blogspot.in


Related Post :-

1. Simple Calculator Program in JavaScript 

2. Animated moving car program : computer graphics in c

3. Interesting C++ Program

4. How we add a " Find us on facebook " link to blogger 

5. How to Add a Custom Favicon to blogger 






Comments

  1. Replies
    1. 10nx Nikhil..
      stay tuned with i-World-Tech.blogspot.in

      Delete
  2. nice GAME....10nx 4 sharing..:)

    ReplyDelete
  3. how to run batch file ??

    ReplyDelete
  4. @Anonymous..
    you Write a batch file in notepad and save it as anyname.bat Now You Open with command Prompt, it will show you the output..

    ReplyDelete

Post a Comment