Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Need help creating text based trivia game

Author
Message
jgillies
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 21st May 2009 06:16
Hi, I am trying to create a text based trivia game. I am using Text-Adventure template to create the questions and answers.

I want it to ask a question and list 4 possible answers. The user will type a number that corresponds to the correct answer. Now I want it to keep track the number of correct answers and I want a time limit the user has to answer the question, as well as displaying how much time the user has left.

Here is what i have to start:


Also, how do i center the words instead of having them in the top left corner and how do i change the size of the font?
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 21st May 2009 11:24
you can change the position of it using Set Cursor X, Y
and for the number of correct answers, just take a variable, and increase it when the user has an answer right



and for the timer, you'll need a loop for that. maybe you can use pluto's Create Zork tutorial, cause he explains there how to make a game with much ROOMS (or questions in your game) without actually programming every room (Question)

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
jgillies
15
Years of Service
User Offline
Joined: 20th May 2009
Location:
Posted: 21st May 2009 13:11
How do i keep track of the amount of correct/incorrect answers to display them at the end?
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th May 2009 10:35
I'm not going to answer all your questions at once but I'll try my best. I just hope I don't insult you.

You can keep all the questions, right answers, and possible answers in a multi-dimensional string. It's easier to work with and can make the code less complicated... by that I mean not using GOTO.



Here you have one array with multiple strings. The 50 is the max number of questions (counting zero) so you have room for 51 questions. xx represents each question number from 0 to 50. The line starting with "Question$(xx,0)" shows that the first string 0,0 will be the first question followed by (0,1) which is the right answer to the question, then (0,2) to (0,5) are the choices to that first question.

Here's how your first question should be defined:


Using the GET DATE$() command is the easiest way to get the current date (without having to change the answer each day).

A second and third question would look like this:


To repeat something over and over again you can use a DO/LOOP. Showing the question, possible answers, user input, and the answer check can all be in the DO/LOOP.

There's no need to check every answer like you've been doing. You only need to check for the right answer against the input... anything else is wrong. You can use the standard (pseudo code): If this=that then do this else do this.




The tile of the game is outside the DO/LOOP so it won't be seen again after the loop has been entered. In the loop the user is shown the question, possible choices, asked for input and the input is checked to see if it's right. The answer check is basically the same as your code except it just checks for the correct answer only and increases the right answer variable... if the string is anything but the right answer it increases the wrong variable. When the program sees "LOOP" it goes back to the start of "DO" and does this till it sees the command "EXIT" (when it checks if CQuest is equal to 2).



This part just shows the end results (after the loop has been exited). If you want to show the score and/or the right or wrong answers while the questions are being asked just move this inside of the DO/LOOP.

Here's all the code put together:


Always avoid GOTO if you can. It's a useful command but there are easier ways to do it. I hope this helps.

Login to post a reply

Server time is: 2024-11-24 06:31:47
Your offset time is: 2024-11-24 06:31:47