Quiz game, is it possible with gdevelop?

Hello,

As the title says, I want to create a quiz game where you have different 2d scenes and each have questions in them that upon answering play certain animation, is it possible? If it is possible, is it reasonable to use GDevelop for such a game?

I’ve been trying to find any tutorial that explains how to making a quiz game but I haven’t been able to find one.

Yes, it’s possible and very doable in GD :slight_smile:
Here, in the discord chat, Bouh has shared his wip game, a monuments quiz: https://discordapp.com/channels/258623956158906368/377571085643677696/518147526176800768

I never did a quiz game, but I guess the hardest part is setting up the list of questions and answers, structures almost mandatory, and if you do it right you can even do it in one or two scenes :wink:

Awesome, I’ll try to run that game.

How I’m thinking is I will have to add global variables for each question and have a checker that checks whether all questions were answered to change to scene which shows which questions have been answered correctly (sort of end game screen).

What I’m not sure about is how to approach this, have global variable for each question which can be 0 (unanswered), 1 (answered correctly) or 2 (answered incorrectly) and then have a condition which checks whether all variables have either 1 or 2 for game to change to end game scene?

I hope I’m thinking the right way. Would you be able to explain concept of quiz game’s functionality, at least briefly if I’m thinking the wrong way?

It would be a bit long to explain in detail, but in summary (I’m improvising):
You need a main scene to show all the questions, a structure variable (scene or global) with the list of questions, a global variable with the current question index, and two global variables with the number of corrects and incorrect answers.

The structure should look like this:

Questions 1 question "Is yesn't a valid word?" answer1 "Yes" answer2 "Yesn't" answer3 "Non't" correctAnswer 2 2 question "Is the Earth flat?" answer1 "No" answer2 "Of course not" answer3 "iS tHe EaRtH fLaT?" correctAnswer 3 ...

So to access the second question you do:

VariableString(Questions.2.question)

Or dynamically as you’ll need it:

VariableString(Questions["2"].question)

The global variable that stores the current question index will be “currentQuestion” and must start at 1.
With this index you access the question (as described above but using the “currentQuestion” variable) and show it in a text object.

Then you’ve to show the possible answers, you can separate text and button, but I’ll use the text as a button for simplicity. For example for the third button you have to set two values, the text with the answer and a value with the answer index:

Do = VariableString(Questions[GlobalVariableString(currentQuestion)]["answer" + ToString(3)]) to the Text of AnswerText Do = 3 to variable "answerIndex" of AnswerText

The last step is checking the clicked answer, it will be correct if the “answerIndex” variable of the button is the same than the correct answer (it’s saved in the structure). If the value is correct increase a “corrects” global variable, otherwise an “incorrects” variable. Then increase the current question index and reset the scene to go for the next question:

[code]Conditions: Left mouse button pressed
Cursor is on AnswerText

// sub-event
Conditions: Text of variable "answerIndex" is = VariableString(Questions[GlobalVariableString(currentQuestion)].correctAnswer)
Actions: Do + 1 to global variable "corrects"

// sub-event
Conditions: Text of variable "answerIndex" is != VariableString(Questions[GlobalVariableString(currentQuestion)].correctAnswer)
Actions: Do + 1 to global variable "incorrects"

// sub-event
Conditions: No conditions
Actions: Do + 1 to global variable "currentQuestion"
         Change to scene "ThisSceneNameAgain"[/code]

Done, that should be enough to get an idea. Of course there are lots of things to do: creating the buttons, set and use their index correctly (here I’ve used a fixed “3” for the third button), you’ll want to test if the current question index is greater than the number of questions you have, and if so go to the game over scene to show the number of corrects and wrong answers (that’s why these variables are globals), etc. :slight_smile:

There are also two extra things you can do, but I didn’t explain here because it’s a topic itself: show the questions in a random order (right now they will always follow the same order) and randomize the answers position, you can even put extra wrong answers to pick them randomly too. Just a lot of extra polishing design :smiley:

1 Like

That’s very thought-out and easy to follow explanation, I really appreciate the time you took to compose it, thank you! got the game working quite quickly!

I also made array to track which questions were answered correctly so I can present to the player which questions were answered wrong at the end scene.

I’m still struggling with one thing, in my quiz game, questions are buttons in multiple scenes, how do I keep changes in the scene so that when question button is pressed, it is deleted so player will see that he answered that question. Also, animation I was talking about happens in different scene from quiz one, is it possible to do that?

Example:
You press question marker, scene changes to quiz, you answer quiz, it changes back to previous scene (already done that), question marker is deleted and certain animation plays, new object is created that stays there for the rest of playtime.

Edit:
Is checking whether question is answered (from array) at beginning of scene and deleting object if it’s true great way to deal with this or is it inefficient?

Checking the array and deleting objects at the beginning of the scene is the best solution indeed, it will happen in a single frame and will be super fast anyway, it won’t lag, you won’t notice it :smiley:

For a future project keep in mind that you’ve the action to pause a scene: You’ve this scene that has the list of quizzes, when you select a quiz go to that quiz scene, after finishing it go back to the paused scene, show an animation for the finished quiz and delete the button. When you select another quiz, pause again the scene and so.
This way you don’t have to “reconstruct” the main scene deleting all the objects, just update the last quiz button and animation.

What matters is getting it working, if it’s already working the other way is perfect :wink:

I’m making a platform game for my pupils, for reviewing maths. I want a question (a math operation) to be activated when they touch a treasure chest. If they answer correctly the box will open and they will receive a coin. How can I do that? Do you have a template? Thank you.

Redirection to this post.