How to make score change as the distance change

I know how to make score change by variable but I want to know how can i do that when player go up 80 Pixels the score increase by +1

Another way of saying is how can i make a connection that when each time 80 pixel of distance is covered the variable changes by +1

round(player.X() - start.X())

01

2 Likes

Thanks, its close. What i actually need is to change the score by +1 as player go up 80 pixels & score by -1 as player go down 80 pixels. 80 pixels is equal to one floor in my game

I have found a way of doing it but its takes longer and many scripts, there should be a way that when player y position changes by 80 pixels, score variable add +1

Here’s one way of doing it:

Condition: Omar is on the floor
Action: Score = 1 + ((1020-Omar.Y())/80)

1 Like

Thanks I recently tried it worked perfectly but sometimes the variable becomes long decimal valure like 3.0000011111122 or 5.0000011122

How can i round off or make decimal disappear?

Round it using the round function

how to add round function

Add Round(Variable) to the action parameter
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/expressions-reference#mathematical_tools
You can see the round function there