How do I create random math problems

Just started using Construct 2? Post your questions here

Post » Fri Dec 30, 2016 8:28 am

Hey guys im designing my first game!! been wanting to do this for a long time for my kids. This game is a platformer that you have to collect coins. they are inside chests. To open the chect you have to answer a random math question. My problem is that I cannot seem to create a random question. Im probably doing it all wrong but could someone point me in the right direction? thanks in advance.

This is what ive been trying in a text field

round(random(0,10)) " + " round(random(0,11)) " ="
says there is a syntax error with the " + "

what would be the best way of achieving what i want?

I would also like to know how you guys would handle the answering of these questions. Do i put a text box in and do a function to compare the values, then tell it to move on with the game?
B
4
S
1
Posts: 6
Reputation: 312

Post » Fri Dec 30, 2016 4:32 pm

It should be:

round(random(0,10)) & " + " & round(random(0,11)) & " ="

Don't forget to put & to concatenate the strings :)
B
18
S
9
G
17
Posts: 84
Reputation: 10,519

Post » Fri Dec 30, 2016 10:13 pm

thank you very much. ill remember that for next time. Its been so much fun learning this. How would you setup the answering of the question? I would like the player to put the answer in a text box and it would check it its correct when the button is pressed.
B
4
S
1
Posts: 6
Reputation: 312

Post » Sat Dec 31, 2016 12:41 am

Message: michaellankshear can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Hey guys, still having issues with this. I followed the tutorial from https://www.scirra.com/tutorials/4810/math-quiz-simple-equation. But cant seem to get the text to display. Can someone please tell me what im doing wrong. Ive attatched the capx file below


http://www.filedropper.com/zeeba
B
4
S
1
Posts: 6
Reputation: 312

Post » Sat Dec 31, 2016 1:26 am

I'm looking at your capx, I will try to look at your problem.
B
18
S
9
G
17
Posts: 84
Reputation: 10,519

Post » Sat Dec 31, 2016 1:35 am

I found your problem :) You just forgot to include the event sheet where your function Create is written.
B
18
S
9
G
17
Posts: 84
Reputation: 10,519

Post » Sat Dec 31, 2016 1:46 am

thank you soooo much!! This is something i didnt know. I knew it would be something simple. Thanks again
B
4
S
1
Posts: 6
Reputation: 312


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest