How do I convert a float to a int?

Get help using Construct 2

Post » Fri Sep 23, 2016 8:57 pm

Hello friends, i'm making a game that gets a score by the max height the player can reach, but the value of player.y is everytime a float like "108.108846150" and this is poor for the design. So how do I convert this float value "108.108846150" to a simple int "108"? Any ideas?
Image
B
12
S
3
G
5
Posts: 9
Reputation: 3,198

Post » Fri Sep 23, 2016 9:09 pm

Set ScoreValue to int(player.y)

Alternately floor(player.y), ceil(player.y), or round(player.y)
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Fri Sep 23, 2016 9:19 pm

That's exactly what I wanted, thank you!
Image
B
12
S
3
G
5
Posts: 9
Reputation: 3,198

Post » Sat Sep 24, 2016 5:58 am

Just a thing to tell you that int will alway make the number positive so if you want negative number you will have to use alternative way
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Sat Sep 24, 2016 6:39 am

int() works for negative numbers.

int(3.14) = 3
int(-3.14) = -4
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991


Return to How do I....?

Who is online

Users browsing this forum: MiloMasson, Yahoo [Bot] and 37 guests