Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUIZ GAME WITH SCORE
#1
Im doing a simple quiz game containging the capitals of the world. And Im trying to add score to it so you will get one score for every right.

1.The problem is when you answer right the first time and goes to the second and answer right again the counter resets I have tried a lot of things but cannot come up with any good soulution. Here is the code so you can see and help me better.

2. Another question to how do I do if the user inputs Kabul or KABUL. I have tried to input LCASE$ and those things but I dont get it to work and I dont think it does eiter.
----------------------------------------------------
afghanistan:
INPUT "Afghanistan: ", city$
IF city$ = "kabul" then
goto albania
else
goto afgwrong
end if

afgwrong:
print "Wrong!"
goto albania

INPUT "Albania: ", city$
IF city$ = "tirana" then
goto sweden
else
goto albwrong
end if

albwrong:
print "Wrong!"
goto sweden

'AND SO ON.....................................................

And I'm sure there is an easier way to do this, if you know which you probably do plz write it down :wink:
Reply
#2
Ewwww...Look at all that GOTO.
Code:
INPUT "Afghanistan: "; City$
IF LCASE$(City$)="kabul" THEN
   PRINT "Right!"
   Afghanistan_Correct=1
ELSE
   PRINT "Wrong!"
END IF
INPUT "Albania: "; City$
IF LCASE$(City%)="tirana" THEN
   PRINT "Right!"
   Albania_Correct=1
ELSE
   PRINT "Wrong!"
END IF
'And so on...
At the end, you can just check if the Afghanistan_Correct is equal to 1 or not to see if you got Afghanistan correct. If it is equal to one, then you got it correct. Otherwise, you got it wrong. You can do that with all the other Countryname_Correct variables that you put.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
Hi tabnewflax,

Like all programming projects, there are many ways to accomplish the same thing. If I were wanting to solve your problem, I would structure the program as follows:

1st, create a file containing the countries and capitals as follows:

"IntCaps.txt"
Country, Capital
Italy, Rome
England, London


Then, I'd make the main program read the file into a pair of arrays, 1-containing the countries, and the other containing the capitals. Then, I'd select a random array element, display the country and ask the user for the capital.

The advantage of this method is that you could then use the same program to quiz any two related words...for example, you could make another file containing the "element name" and "symbol" if, for example you were studying chemistry...

another advantage is that all your data is located in 1-place...separate from the program...in a format that is easy to modify. Also, you could give the user choice...take the geography quiz, or the chemistry quiz...and altering it to give the song/artist quiz would be trivial.
Reply
#4
Zack... I don't get how the score things work, and I can't write the underline than it stands end-of-statement. I guess it might be ok to skip the underline, but I dont get it how I shall check it in the end I need a more detailed explanation of how getting the scores together in the end. But thanx for the other stuffs it cleared up a bit.

And thanx Mango for yours too but that is a bit advance for me now I think, I will deal with your idea later Wink
Reply
#5
Quote:Zack... I don't get how the score things work, and I can't write the underline than it stands end-of-statement. I guess it might be ok to skip the underline, but I dont get it how I shall check it in the end I need a more detailed explanation of how getting the scores together in the end. But thanx for the other stuffs it cleared up a bit.

And thanx Mango for yours too but that is a bit advance for me now I think, I will deal with your idea later Wink
Don't worry at all about the underscores (the _ symbols) in the name of the variables. See, an underscore is just another legal character for a variable. Using one doesn't change how the variable acts, or what you can do with it. Just ignore it if you like - you can even change it's name to AlbaniaCorrect or AfghanistanCorrect.

Okay, basically, it asks you for the name of a capital of a country. You enter the name, and it's stored in the City$ variable. Then is compares the lowercase of City$ (LCASE$(City$)) to the correct city (in all lowercase, of course). If you got it right, it says "Right!" and it sets a variable called Countryname_correct to 1. Then, at the end of the program if you want to tally up how many city names you got correct, just check if the appropriate Countryname_correct variable is equal to 1.
See?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#6
GRR! Underscores are not allowed in QB! Tongue
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#7
Unless you hack it.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#8
Quote:GRR! Underscores are not allowed in QB! Tongue
Huh? Yes they are... :normal:
Code:
A_B_C_D=5
PRINT A_B_C_D
Works fine.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#9
Quote:Then, at the end of the program if you want to tally up how many city names you got correct, just check if the appropriate Countryname_correct variable is equal to 1.
See?

I'm sorry that I am nagging so much, but I still don't get how to display the score at the end Tongue
Reply
#10
Whenever you get the answer correct, add an amount to a Score variable, and when it's time to display it, use the PRINT command like this:

PRINT Score%

Remember to use the appropriate variable type. If the score won't ever be higher than 32767, then use an integer (Score%). If it goes higher, use a long (Score&). More info on data types in QB's help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)