How do I display random numbers

Get help using Construct 2

» Tue Mar 04, 2014 10:19 am

I am making a math game. Its a race and to increase your speed you need to answer a math question (2+8) for exsample so i need to random nubers to appear on the screen and answers the player can choose from.
B
3
Posts: 5
Reputation: 206

» Tue Mar 04, 2014 10:27 am

2 options:
Random(range[,....])
choose(0,1,2,3,4,5,6,7,8,15,19,35)

Have a look in manual

edit: use floor with random for whole numbers floor(random(10)) is random 0,1,2,3,4,5,6,7,8,9

See Joskin below posted too, with better explanation
Last edited by DUTOIT on Tue Mar 04, 2014 10:32 am, edited 3 times in total.
You think you can do these things, but you can't, Nemo!
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,743

» Tue Mar 04, 2014 10:27 am

Hi,

For random number use the random() function.

random(x)
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.

random(a, b)
Generate a random float between a and b, including a but not including b.

For the display use the text object or a sprite font.
B
40
S
15
G
5
Posts: 295
Reputation: 6,129

» Tue Mar 04, 2014 10:47 am

You would need a global variable for each number to check if the answer give adds up to correct amount
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

» Mon Mar 10, 2014 10:52 am

see this CAPX and work it out
You do not have the required permissions to view the files attached to this post.
B
262
S
48
G
15
Posts: 2,009
Reputation: 42,183