GameSalad

How can I Display Text of distance actor travels? (like on Doodle Jump)

thevoxptythevoxpty Posts: 38Member, BASIC

So I am making a jumper game similar to Doodle Jump and can't decipher how to Display Text of distance that my actor travels upward.

So, the scene dimensions are 800 width by 50,000 height. If anyone has a trick up their sleeve about this one please let me know. THANK YOU

Comments

  • Two.ETwo.E Posts: 366Member, PRO

    If the actor is moving through the scene. You can just use the actors Y position minus the starting position. Then multiply or divide that value to determine how much the "distance" changes.
    Best
    Two.E

  • thevoxptythevoxpty Posts: 38Member, BASIC

    @Two.E Thank you first of all. Could you write the formula down for me please?... I know most of it but when it gets to the multiply or divide this value... I get lost.

  • tatiangtatiang Posts: 11,039Member, Sous Chef, PRO, Senior Sous-Chef
    edited August 20

    In the player actor:

    Change attribute self.StartingY to self.Position.Y
    Constrain attribute game.distanceTraveled to self.Position.Y - self.StartingY

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • thevoxptythevoxpty Posts: 38Member, BASIC

    Thank you @tatiang , that worked out wonderfully!

  • pHghostpHghost London, UKPosts: 2,062Member

    @thevoxpty said:
    but when it gets to the multiply or divide this value... I get lost.

    You multiply or divide it depending on how you want it to show. For example, if in your game 128 points of resolution = 1 km, and you want to show the distance traveled in km, then you need to divide the result by 128, etc.

  • thevoxptythevoxpty Posts: 38Member, BASIC

    Thanks again @pHghost

  • thevoxptythevoxpty Posts: 38Member, BASIC
    edited August 21

    So my game is like Doodle Jump, where my actor jumps and gains distance as it goes up; the distance-reader is reading the pixels gained on screen, it's fine... but, it reads with decimal (0.000) and it's already set on integer... I'm guessing it's the nature of reading screen pixels that forces there to be a decimal system...?

    Is there a way/formula to eliminate the decimal system in this situation?

  • tatiangtatiang Posts: 11,039Member, Sous Chef, PRO, Senior Sous-Chef

    If your attribute is an integer then the value that appears will be an integer. If you used a real attribute, you will need to convert it to an integer by using the math function round as in round(game.distance).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Posts: 11,039Member, Sous Chef, PRO, Senior Sous-Chef

    /merged threads

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • thevoxptythevoxpty Posts: 38Member, BASIC

    Thanks a million @tatiang , very helpful!

Sign In or Register to comment.