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
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

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
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Sat Sep 24, 2016 6:39 am

int() works for negative numbers.

int(3.14) = 3
int(-3.14) = -4
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest