qustion game

This is a discussion on qustion game within the Game Programming forums, part of the General Programming Boards category; im making something like jeopardy where you have qustions and such. But what i was wondering how can i do ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    25

    qustion game

    im making something like jeopardy where you have qustions and such. But what i was wondering how can i do random qustions. and how should I go about making the qustions so they can be read. Dont do it for me, just some hints thats all... chow

  2. #2
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    Try assigning each question a variable, say, if you have 100 questions, number them 1-100... then do a random number between 1-100, return the value you get thru a function, whatever is returned display that question...

    just a thought :d

  3. #3
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    I think this should be easy. I would use a 2D array with all the questions in it:
    Code:
    char question[number_questions][]={"question".....};
    then use rand function to generate a random value and put it in the question array. . You can run it in a do, while loop. Oh, you should write a function that prevent the rand generates a number twice, since you have a do loop. Well it's all up to you
    Hello, testing testing. Everthing is running perfectly...for now

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    I don't know much about the STL but I think a std::map might be a good choice.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    i really dont know much about 2d arrays. but im sure inm y text book they mention it.. any more ideas or hints.

  6. #6
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    Quote Originally Posted by Gardul
    i really dont know much about 2d arrays. but im sure inm y text book they mention it.. any more ideas or hints.
    2D array is not that hard to understand. Ok, just imagine you need 3 char variables array. Normally, you'll do like this:
    Code:
    char a1[]="first";
    char a2[]="second";
    char a3[]="third";
    Well, it's kinda long to declare like that, how about combine them into one. So we have:
    Code:
    char a[3][] = {"first", "second", "third"};
    ta da!!! Now you have a 2D array character. Pretty simple heh.
    Hello, testing testing. Everthing is running perfectly...for now

  7. #7
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    Or if you are a C++ man. You can use strings which then you could just use a single array.
    Woop?

  8. #8
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    Quote Originally Posted by hdragon
    2D array is not that hard to understand. Ok, just imagine you need 3 char variables array. Normally, you'll do like this:
    Code:
    char a1[]="first";
    char a2[]="second";
    char a3[]="third";
    Well, it's kinda long to declare like that, how about combine them into one. So we have:
    Code:
    char a[3][] = {"first", "second", "third"};
    ta da!!! Now you have a 2D array character. Pretty simple heh.
    I just read about that actually... I will have to give that a try. and yes I do use C++ Dev.. i was thinking maybe how boreland is soon.

  9. #9
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    Quote Originally Posted by prog-bman
    Or if you are a C++ man. You can use strings which then you could just use a single array.
    Oh well, yeah, forgot about string. String would be good for this kind of stuff
    Hello, testing testing. Everthing is running perfectly...for now

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    25
    Quote Originally Posted by hdragon
    2D array is not that hard to understand. Ok, just imagine you need 3 char variables array. Normally, you'll do like this:
    Code:
    char a1[]="first";
    char a2[]="second";
    char a3[]="third";
    Well, it's kinda long to declare like that, how about combine them into one. So we have:
    Code:
    char a[3][] = {"first", "second", "third"};
    ta da!!! Now you have a 2D array character. Pretty simple heh.

    hmm qustion.. {"frist" } what do i put in the " "? would the qustion actually go in there? or just a number or something to link the qustion later?

  11. #11
    Computer guy
    Join Date
    Sep 2005
    Location
    I'm lost!!!
    Posts
    200
    Well, you can either use fstream to load the data into the array of characters or you just define it where you create the characters:
    Put the question into the " " marks, like this:
    Code:
    char a[3][] = {"This is question number 1", "This is question number 2", "this is question number 3"};
    So then when you want to call out the first question, you will use:
    cout<<a[0];
    same thing with the others
    Hello, testing testing. Everthing is running perfectly...for now

  12. #12
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    good idea hdragon

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-07-2010, 11:08 PM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21