Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-10-2013, 05:30 PM   #1
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default Notepad game question?

This is my first attempt at any type of programming. Please take a look at the following game I created; is there an easy way to add some lines of code to make it keep score? At the end I would like it go give you a score and then say, press any key to exit...Thank You!

@echo off
cls
echo LOADING GAME
ping localhost -n 5 >nul
cls
@echo off
color 0a
:loop
:menu
cls
echo Hello and Welcome to the Game.
echo You get to...
echo 1) Start!
echo 2) Info
echo 3) Exit
set /p number=

if not defined number (
cls
goto loop
)

if %number% == 1 goto game
if %number% == 2 goto info
if %number% == 3 exit

:game
cls
echo Who are you?
set /p name=
echo Hello %name%!
echo Do you want to start the quiz? (y/n)
set /p start=

if %start% == y goto lvl1
if %start% == Y goto lvl1
if %start% == n goto menu
if %start% == N goto menu
goto startgame

:info
cls
echo Press your desired button and press enter to continue to where ever you are going
echo.
echo Go back? (y/n)
set /p help=

if %help% == y goto menu
if %help% == Y goto menu
if %help% == n goto info
if %help% == N goto info
goto info

:lvl1
cls
color 0a
echo Hello, it's quiz-time, please answer the following questions.
echo An IP Address starting with 192 is what class?
echo A. Class A
echo B. Class B
echo C. Class C
echo D. Class D
set /p !=

if %!% == A goto wrl
if %!% == B goto wrl
if %!% == C goto crl
if %!% == D goto wrl
if %!% == a goto wrl
if %!% == b goto wrl
if %!% == c goto crl
if %!% == d goto wrl
goto lvl1

:crl
echo You Are Correct!
echo.
echo Continue (y/n)
set /p ha=

if %ha% == y goto lvl2
if %ha% == n goto menu
goto crl

:wrl
echo Wrong!
echo.
pause

:lvl2
cls
color 0a
echo Good Job, now it gets a little harder
echo How many bits are in a byte?
echo A. 4
echo B. 8
echo C. 16
echo D. 64
set /p !=

if %!% == A goto wrl
if %!% == B goto crl
if %!% == C goto wrl
if %!% == D goto wrl
if %!% == a goto wrl
if %!% == b goto crl
if %!% == c goto wrl
if %!% == d goto wrl
goto lvl2

:crl
echo You Are Correct!
echo.
echo Dare to Continue? (y/n)
set /p ha=

if %ha% == y goto lvl2
if %ha% == n goto menu
__________________

palermo is offline   Reply With Quote
Old 02-12-2013, 05:35 PM   #2
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Notepad game question?

You're already using the set command to set some variables - you just need another for the score, which you can then add to and display as and when you choose!
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 02:54 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0