# How do I invert the Y value?

Get help using Construct 2

### » Mon May 12, 2014 9:33 am

Hi everyone, I'm tinkering with a game idea I had which is a vertically scrolling platformer.

The problem I'm having is trying to figure out how I should/could set the score value according to the height of which the player has gotten to as the Y-value starts at 0 at the top of the screen and increases downwards (i.e. the opposite of what I want) and also a way of normalising the scores since the Y-values I'm getting right now are the raw Y-values which are derived from the layout's height.

An example would be a game like http:// www. scirra .com/arcade/action/6344/piggy-jump but with a scoring element to it. Perhaps a 0-99 range for the first "screen" and a 100-199 range for the second "screen" and so on...

Would appreciate any tips or suggestions!
B
9
S
1
Posts: 12
Reputation: 621

### » Mon May 12, 2014 9:43 am

Player.Y * -1

Inverts the y value

200 * -1 = -200

-200 * -1 = 200
B
52
S
9
G
2
Posts: 153
Reputation: 3,508

### » Mon May 12, 2014 10:31 am

Thanks for your reply but that doesn't seem to work for me. The problem is, I'm not getting a negative value in the first place. I'm getting something like 1821 when it's at the bottom of the screen and it decreases as the player travels upwards.

EDIT: Doh! I've managed to answer my own question. I just had to subtract the heights of the player and the ground it is on to get the correct values. Thanks!
B
9
S
1
Posts: 12
Reputation: 621

### » Mon May 12, 2014 5:18 pm

You can also use the abs expression to always get a positive value.

e.g. abs(-127) = 127
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

### » Tue May 13, 2014 3:32 pm

eli0s wrote:You can also use the abs expression to always get a positive value.

e.g. abs(-127) = 127

Yup. I'm using that now after stumbling upon it last night. Thanks anyway!
B
9
S
1
Posts: 12
Reputation: 621