Trivia Game Help with Tables

mrchris317mrchris317 Member Posts: 78
edited January 2013 in Working with GS (Mac)
Hey guys I want to make a trivia game. I assume I need to use tables for this. I want to have questions generate randomly from a bank of questions. Then they will have predetermined answer choices.

Example- Which color is not in the rainbow?
a- Blue
b- Green
c- red
d- gold

The player would tap gold and be awarded a point and then next question would play, etc.

The things is, I dont know how to do any of this. So if you can help me out by pointing me in the direction of tables that store the questions and answers, the variables, the changing questions, right vs wrong answer and anything else need to make a trivia game like this, I would really be grateful. Thank you.

Chris

Answers

  • mrchris317mrchris317 Member Posts: 78
    Dont know if anyone saw my question, so Im giving it a quick bump. Sorry if this is not good practice, but I didnt know what else to do. Thanks.
  • PixelMetalPixelMetal Member Posts: 283
    edited January 2013
    You also need a table value to define which is the correct answer. If you want a variable # of answers, you'll need another table value to tell GS how many answers there are. And don't forget, another table value for the question. Then to choose a random question, it chooses a random row from the table, with one row for each question.

    For example, a single row in your table would have this format:
    [Question]
    [# Answers]
    [Correct Answer]
    [Answer 1]
    [Answer 2]
    [Answer...etc]

    That should get you started.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Start by google or forum searching for "gamesalad tables" (that search without the quotes resulted in 5 videos just now). You can learn some basics about tables, even if they apply to other kinds of projects. You can also search for "gamesalad pick random table" (again, without the quotes) and you'll find more than enough to get you started.

    A trivia game is not hard to set up in tables, and @PixelMetal has given you some good ideas. But if that's over your head, back up and learn from videos and other resources here on the forums.

    If you get stuck, post a screenshot of your rules or some more information about what you tried and we can give you assistance.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • mrchris317mrchris317 Member Posts: 78
    ok awesome:) Thanks both for your help. I appreciate it:)
  • mrchris317mrchris317 Member Posts: 78
    Hey guys, I watched the tables tutorials. They were very helpful. Now I have some follow up questions.

    1) If I have 100 questions and each question has 4 answers, do I have to make a table of all questions and a table of all answers or I can put them in 1 table.

    2) How do I make the questions appear random, but the app knows not to display that question again within the same game.
    Example- Question 2 appears and is answer, I dont want it to show up again in that round.

    3) How do I make it so it knows which is the correct answer?

    4) How can I trigger a right/wrong response when an answer is correct (similar to question 3).

    Im thinking the scene will have 5 actors. 1 that displays the questions from the table. Then 4 actors to display a response each. Each of those actors will have a touch behavior. Is this correct?

    Thanks for all your help.

    Chris
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    1) Either way is fine. I would recommend creating a table for displaying the answers (and the question if you like), and then a separate table for holding the correct answers, since each question only has one correct answer. Just make sure that you figure out the formula for where an answer is stored. For example, if you have questions in a separate table, then question 1 would be in row 1 and its display answers would be in rows 1-4 of the DisplayAnswers table. For question 2, the display answers would be in rows 5-8 of the DisplayAnswers table. So to generalize, the first display answer would be found in row (4*questionNumber-3), the second display answer would be found in row (4*questionNumber-2), etc.

    2) If you Google "gamesalad random without repeat" (without quotes), you'll have your answer. One way to do it is to put all possible question numbers (i.e. table row numbers) in a separate table and then choose a random(1,tableRowCount(TableName)) question row and delete the row that was chosen after you use it. If you loop through that, each time a row is chosen, it will be deleted from the separate table and never used again.

    3) Check the table value against the guess that was inputted. You have to create an attribute to temporarily store the guess that was made (e.g. "gold"). You can do this with a text attribute and then compare it to the table cell that holds the answer for that question.

    4) Use Rules. When game.currentGuess is tableCellValue(|T| CorrectAnswers,game.questionNumber,1) ... [celebrate, hug someone, display particles, spawn a cute penguin, award the player points, ...]

    *I've started naming all of my tables with |T| at the beginning because it makes them easier to find in the expression editor.

    Yes, five actors. You're thinking right!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • mrchris317mrchris317 Member Posts: 78
    Hi tatiang, thank you for your help. Im really having trouble grasping how I make my actors display the answers to the random questions so that everything matches.

    I am able to display the question randomly (although it repeats), but I am not able to match the correct answers to the correct questions.

    I am also not sure how to make the questions right or wrong. I watched the videos you suggested but I am still unsure.

    So, I need to know how to randomly display the question (without repeating), with corresponding answers (that also dont repeat).

    I need to know how to select the appropriate answer to add to the score, and make sure the wrong answer is selectable but gives a different outcome than the right answer.

    I also need to know how to go to the next question.

    Im really bad with this stuff. Thank you for all your help and to anyone else who has helped or wants to help in this instance.

    Chris
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @mrchris317 What you're asking is beyond the scope of what I can offer in a forum such as this. Someone else may have time enough to cover all of it, but I can at least offer fee-based help if you're interested. I could either build the project for you -- which would take less time -- or teach you how to do it -- which would take more time but follow the whole "if you teach a [person] to fish" proverb.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • mrchris317mrchris317 Member Posts: 78
    @tatiang Sent message. Thanks.
  • dyllandyllan Member Posts: 35
    I wouldn't do it with tables. I would do it when touch is pressed/released to display text "Correct" then change scene or whatever your next question is on. That would be much easier.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @dyllan You're suggesting creating a new scene for each question. There's nothing wrong with that idea except that if you have 300 questions, you'll be building 300 scenes. And then when you decide you need to change the location of an actor or an instance rule, well, you'll be doing it 300 times. Or if it's on a single scene, you'd be using 300 text attributes for the questions plus 300*4 text attributes for the answers. That's a pain to manage.

    The discussion started in January, but I've been building the app for mrchris317 since then and it's close to release. And yes, we did use tables. ;)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zohrabzohrab Member Posts: 1
    Is it possible that step 3 and step 4 mentionned above doesnt work properly with PC users?
  • VolontaArtsVolontaArts Member Posts: 510
    @tatiang wouldnt 300 scenes be a horribly slow game?
  • guillefaceguilleface Member Posts: 1,014
    you trying to do all steps at once, try go step by step, thats how i do it and it helps.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Although this is an old post, the Trivia template we have on marketplace is compatible with the latest Windows version, has non-repeating questions logic, allows for picture answers as well as the normal text answers, and has multiple layouts for the answers. Questions will only repeat if all of the questions have been asked.

    http://marketplace.gamesalad.com/#query=trivia&product=16610
Sign In or Register to comment.