Quiz Game

Talk about making games.

Quiz Game

Postby jman » Sat Sep 12, 2009 1:26 pm

hi i am going to make a quiz game and i have a question... how would you make each question come up randomly??
all help appreciated :D
Labyrinth-just starting
User avatar
jman
 
Posts: 123
Joined: Fri Jul 20, 2007 7:07 pm
Location: Ontario, Canada
Score: 2 Give a positive score

Re: Quiz Game

Postby skydereign » Sat Sep 12, 2009 2:23 pm

You would use rand. Just say you have a data base of questions, maybe held by an array. On the event that pulls up questions, it would do something like this.
Code: Select all
int randomQ = rand(2);
switch(randomQ)
{
    case 0:
    strcpy(textActor.text, "Question number one is?");
    break;

    case 1:
    strcpy(textActor.text, "Does this make sense?");
    break;
}


It may differ, but this is the general idea. So you know, rand picks a random number from zero to the int one less than the number, so in this case 0 or 1. Since it can be only two possibilities, I have two cases in the switch statement, but you would have more, one for each question.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Quiz Game

Postby jman » Sat Sep 12, 2009 3:15 pm

ty.. :D :D :D

PS: do you sit on the computer all day just to answer all of my questions?? :lol: :lol: :lol:

keep up the good work
Labyrinth-just starting
User avatar
jman
 
Posts: 123
Joined: Fri Jul 20, 2007 7:07 pm
Location: Ontario, Canada
Score: 2 Give a positive score

Re: Quiz Game

Postby fuentesmith » Tue Sep 15, 2009 5:19 am

There is one inbuilt function in VB.net named Random. With the help of the Random Function, each time a random number is selected from the list of numbers.
fuentesmith
 
Posts: 3
Joined: Fri Sep 11, 2009 10:35 am
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest