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

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
ping localhost -n 5 >nul
@echo off
color 0a
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 (
goto loop

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

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

echo Press your desired button and press enter to continue to where ever you are going
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

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

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

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

echo Wrong!

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

echo You Are Correct!
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,434
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

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 10:29 AM.

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