How do I invert the Y value?

0 favourites
  • 5 posts
From the Asset Store
Check preview, download and add value to your games.
  • 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:// 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Player.Y * -1

    Inverts the y value

    200 * -1 = -200

    -200 * -1 = 200

  • 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!

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

    e.g. abs(-127) = 127

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)