A while back I posted a five part series on how to create a trivia game using Construct 2 where I posted links to the Construct 2 solutions for each post. Recently (as of a couple of days ago) I decided to post an updated Trivia Template to my GitHub. I did this so that anyone can pull down the Construct 2 solution, leverage the template, and create some quick and awesome trivia games. I spent a lot of time creating logic to read questions in from a text file (local or on a server), randomizing questions, and the overall UI of a trivia game. In this post, I want to walk through the different things you can and should customize from my template.
The first thing to know is that this Trivia Template is built on top of the Game Template. So, all of the logic from that template is included here. If you haven’t seen my post on the Game Template, you can find it here. I encourage you to take a look at that post, but I will try to cover everything here as well.
Let’s start with the general page navigation of the trivia template, which includes four pages: Home Page, Game Page, End Page, and About Page. These pages are pretty self explanatory, but just in case, let me take a second to explain. You start at the Home Page where you can either click to go to the About Page or press play to start the Game. When you lose or time expires, you are taken to the End Page where you high score is displayed. From the End page, you have the option of restarting the game or going back to the home page. Simple enough I hope!
There is a lot going on in this template, but I don’t want you to feel overwhelmed. I will walk you through the things that you can/should customize. First off, for global variables that have “**UPDATE**” in the description, you should…yep, you guessed it, update. You can see an image of the ones from the game logic below. These include the name of the file that holds your questions, the number of points to award the player for a correct answer, the length of the timer in seconds, and the number of questions that you want to read in from the file.
These variables are pretty straight forward, but remember that you can either use a local text file to hold your questions or load them from a server. I am using the AJAX object here, so either way is fine. Remember if you load from a server, your user will need internet connection. The plus side there is that you can edit your questions file without having to repackage the game. Up to you which route you choose.
Now, since I started talking about the file that holds the questions, this is a nice Segway into the formatting of the questions. Here is an example.
Question?; Answer Choice 1; Answer Choice 2; Answer Choice 3; Answer Choice 4; Correct Answer; |
Notice that the question, the four answer choices, and the correct answer all end with a semicolon. Notice also that the each set of question and answer choices ends with the “|” character. So, if you have multiple questions –which I hope that you do- they would look like this back to back.
When was Michael Jordan born?; 1967; 1963; 1960; 1971; 1963; | When was Kobe Bryant born?; 1978; 1981; 1975; 1971; 1978; |
There’s already dummy data in the text file included in the template, so you can just follow the format from there. Besides the aesthetics of the game (text size, fonts, background, etc.), that pretty much covers everything you need to know to get started. One last thing to mention, however, is the this template is optimal for asking the user a subset of a given set of questions. In other words, let’s say on average they can answer 15 questions in the length of time you determine for a round. Then, you should have a total number of questions around 30 or so to pull from. I designed the template this way so that the user wouldn’t see the same questions over and over. It would be randomized.
Want to see an example of how I created a trivia game from the template? Check out “What’s Your Capital” on Windows 8 and Windows Phone. Please leave feedback. If you are interested in the source code project, let me know!
I hope that it gives you a head start and makes things a little easier. If you have any comments or suggestions, please add them below. Alternatively, you can find me on twitter, @jquickwit.