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

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 Member Posts: 599

    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

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 302

    @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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited August 2017

    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

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 302

    Thank you @tatiang , that worked out wonderfully!

  • pHghostpHghost London, UKMember Posts: 2,342

    @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.

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 302

    Thanks again @pHghost

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 302
    edited August 2017

    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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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 Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    /merged threads

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

  • Simple Gamer ArtsSimple Gamer Arts Member, PRO Posts: 302

    Thanks a million @tatiang , very helpful!

Sign In or Register to comment.