GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

Posts: 163Member, PRO

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

• Posts: 431Member, BASIC

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

• Posts: 163Member, PRO

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

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

• Posts: 163Member, PRO

Thank you @tatiang , that worked out wonderfully!

• London, UKPosts: 2,282Member

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

• Posts: 163Member, PRO

Thanks again @pHghost

• Posts: 163Member, PRO
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?

• Posts: 11,288Member, 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

• Posts: 11,288Member, Sous Chef, PRO, Senior Sous-Chef

/merged threads

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

• Posts: 163Member, PRO

Thanks a million @tatiang , very helpful!

Sign In or Register to comment.