I want to make simple addition game for my kid, only up to number 10…I made already game which works good but thing is that I use sprites instead of arrays to input combinations e.g 3+2…And for each combination I use one scene…For 100 combinations it is a bit crazy to use 100 scenes, I know…Is anyone who can help me with arrays?..My idea is to make it more simple to load arrays like (3+4) to text and to give String value to that so when child type number into entry text if input match with current String value get played sound OK…Please give me some lead!!!

Not sure if I understand so, do you pick a random addition operation like 3+2, 6+3…etc that you currently store on individual scenes and the player need to enter the sum and test if the sum was correct or not?

If that’s the case it is pretty simple and you need only 1 scene.

At the beginning of the scene pick two random number in range 1 and 5 and store them in a variable and also calculate the result up front and store that also in a variable.

Condition:

At the beginning of the scene

Action:

Do = RandomInRange(1,5) to the value of scene variable ‘number1’

Do = RandomInRange(1,5) to the value of scene variable ‘number2’

Do = Variable(number1) + Variable(number2) to the value of scene variable ‘sum’

That’s it. You have reduced 100 scenes to 1.

Then, when the player enter anything in to the text input field, attempt to convert the string value to a number value

Condition:

Return key is released

Text of Entry is != “”

Action:

Do = ToNumber(Entry.String()) to the value of scene variable ‘entry’

If the player enter letters instead of numbers, it is going to return 0 and assign it to ‘entry’

Finally, you just need to compare the value of sum and entry

Condition:

The scene variable sum = Variable(entry)

Action:

Correct…Happy face

Condition:

The scene variable sum != Variable(entry)

Action:

Incorrect…Sad face

Then in order to start again, just load the same scene again, no need 100 scenes.

Hello ddabrahim,

Thank you so much for your time and your effort trying to help me. I appreciate that much!..Thank you…

I am not sure that I completely understood how you meant to make that…

Here is how I made game…I created first scene and I inserted number sprites and just one text and entry and scene String variable. And later I just copied first scene and changed sprites and value of scene String variable…It goes fast but I still think that is crazy that I make 100 scenes only for addition…

Later I was thinking to make one text where I can insert random array like 2+3, 4+5… and to assign values to each and later when kid add entry input just to compare values, but to be honest thing is that I am new in all of this and I have no idea…Here is how its look like—>

Please if you have time explain it to me in more detail…

Thank you very much!

Best regards,

David

Not sure if I can explain any better without turning in to some sort of “let’s make” tutorial which I don’t have time to do, but I created an example, you can download it from here, the last item on the bottom of the list (GDevelop5_addition-game.zip):

I did try my best in the comments to explain what I do and why, hope it helps.

Hello ddabrahim,

Great!!!..Thank you so much for your tutorial!..Now I understand way how to do that…I have just one question about random numbers…they just go just from 1-5 so that highest combination, is there any chance to achieve combinations like 7+3 or 8+2…etc… I guess that is more complicated???

Once again, thank you so much for your time!!

Best regards,

David

I haven’t thought of that, so no in the example I shared there is no chance because you pick a random in range 1-5.

Not much more complicated really, so what you could do is pick a random number in range 1-9 for the first number and then for the second number pick a random number in range 1-(10-num1) to make sure the sum of the two number never be greater than 10.

Do = RandomInRange(1,9) to scene variable ‘number1’

Do = RandomInRange(1,10-Variable(number1)) to scene variable ‘number2’

I have updated the example with the changes so you can achieve combinations like 7+3 or 8+2 now.

You are great!..Really…Thank you so much…It works perfect!..

Do you can recommend any literature about learning variables, because I would really like to learn that. Because my son is in the first grade and later I have to try to make more sophisticated things, because downloaded Math games are not point of his interest, but he liked that funny one of 100 scenes I made and he stack on that.

Thank you very, very much for your time!

Best regards,

David

Actually, I have noticed operations with higher numbers like 6+3, 7+3 8+2, 9+1 have been picked way more often than smaller numbers like 1+1 2+3…etc and operations did repeat very often too.

So I decided to go down the more complicated way and fill up a structure with each possible operation using a loop and not manually adding each operartion of course:

Then I also made it so that an operation can be picked only once and it should not repeat, so the player get a different operation each time. Once you get to the end, it start all over but until then should not pick the same operation twice. So the experience is much better.

I have uploaded as a new example you can find it on the same page at the bottom called (GDevelop5_addition-game-with-structures)

Have a look.

Regarding variables and structure, everything is explained on the wiki. If there is anything you don’t understand or have a question you can always ask on the forum.

You are very kind, thank you so much!..Really, thank you very much!..

I changed many things in my 100 scene game and for me it worked perfect. Maybe some combinations repeats more but that is not big deal because my son have to practice long

I tried to make one subtraction scene on same principle, but I got questions like 2-8 where is negative result. I tried to switch number1, number2 options mostly is ok, but at the and I get again questions like 2-8…3-7…

I will check now your updated file…

Thank you so much…

Best regards,

David

My concern was more about operations like 1 + 1, 3 + 2 never come up but instead repeat operations like 6 + 3, 8 + 2 over and over again. The new example with structure fixes that.

Well, it got more to do with logic and math than variables. I’m not very good at math, I also do tons of trial and error until I can figure out formulas that works and do what I want it to do, so I’m not very good at explaining math but I managed to modify the example with structures to be a subtraction game.

I have uploaded as a new example, you can download from the same page called “GDevelop5_subtraction-game-with-structures.zip”

Take a look.

Thank you for your time, you have already done much for me. I appreciate it very much!..I will try to figure out how to fix that…I will check out your new updates…

Thank you…

Best regards…

Thankyou, I’m just starting to learn GDevelop and this looks very helpful.