Get a random number

For questions about using Classic.

Post » Sat Nov 24, 2012 1:05 am

Hi @matcon, here's for a random integer (whole number): int(random(10))
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Tue Nov 27, 2012 7:09 am

[QUOTE=Jayjay] Hi @matcon, here's for a random integer (whole number): int(random(10))[/QUOTE] @Jayjay
It doesn't hurt to do it that way, but it isn't needed. CC automatically returns a number based on the input. When using an integer the return value will be an integer also, when using a float the return value will be a float.

random(10) will return an integer in the range [0, 9] -> 0, 1, 2, ..., 8, 9

random(10.0) will return a float -> 0.015, 3.4127843, 7.1095284, etc.

Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Nov 27, 2012 7:15 am

@tulamide, ah cool, thanks for sharing that
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests