# calculate distance travelled in infinite jumping game

Get help using Construct 2

### » Tue Apr 07, 2015 4:02 am

hi guys I am making an infinite jumping game project which is similar to infinite jumping game template provide by construct 2. Now I want to ask you guys how to calculate the distance travelled by the character, which means how height the character has jumped already. Sorry that I can't attach the project here due to my rep below 500.
B
6
Posts: 49
Reputation: 354

### » Tue Apr 07, 2015 5:15 am

You couldn't attach it even then, its been borked for awhile... use an external free file host like dropbox then post the text version of the url until you get url capabilities.

Follow the code provided in this thread but change X values to Y:
https://www.scirra.com/forum/viewtopic.php?f=147&t=128393

In your case you won't have a finish Y, so just use the start Y and current Y to calculate distance in pixels travelled upward. You can convert that into whatever measurement you like as well (ie. pixel = a foot, divide by 13 and call them Quadroons, whatever fits your game).
B
37
S
8
G
3
Posts: 534
Reputation: 4,986

### » Wed Apr 08, 2015 9:00 am

Message: Hardyanto can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
hi @chrisinfinger , I do not understand what you are talking about. here is my game project capx https://www.dropbox.com/s/wvj9pxth6hw3t ... .capx?dl=0
Can you help me calculate the distance travelled? Thank you
B
6
Posts: 49
Reputation: 354

### » Wed Apr 08, 2015 10:04 am

I tried to open the capx but dropbox says it can't find it (yes, I took out the ...).

My prior explanation only works if your using a set background image and scrolling downward. If your making a true infinite jumper then you will need to measure the height of jumps and add them to a variable that is shown as total height jumped. But the idea is basically the same. You grab current Y when jump is pressed and the max Y when falling animation kicks in or you land. Then you can take the difference and add it to a height variable to post.

The thread I linked to has all the code you just need to remember your using Y and not X values... and your going up so Y values will be subtracting...
B
37
S
8
G
3
Posts: 534
Reputation: 4,986

### » Wed Apr 08, 2015 2:42 pm

B
57
S
23
G
7
Posts: 1,427
Reputation: 10,508

### » Wed Apr 08, 2015 9:31 pm

Cool, I got ~9550 first try (*mumbles*.. then 1595, 1430...) good one Korbaach.
B
37
S
8
G
3
Posts: 534
Reputation: 4,986

### » Wed Apr 08, 2015 10:48 pm

Thanks @chrisinfinger
...It was just a thought..to use Scroll variable for Score(height)
B
57
S
23
G
7
Posts: 1,427
Reputation: 10,508