Jumping

Get help using Construct 2

Post » Wed Mar 20, 2013 2:22 pm

Hey guys, I made a game in which the Player jumps and I need to count the distance he has jumped... can anybody help me how to do it, please? Thanks!
B
3
Posts: 4
Reputation: 308

Post » Wed Mar 20, 2013 5:47 pm

You would need variables to hold the starting point of the jump. Then at the end of the jump you can compare the points from the saved starting point with the point that the player is at to figure out the distance.

You'd start by making two global variables:
StartX
StartY

In the event that starts the jump (let's say pressing the spacebar) you would do something like this:

Keyboard: on key "spacebar" pressed
- System: Set StartX to Player.X
- System: Set StartY to Player.Y
- (do your jump code here)

Then, once the player lands you would use:
distance(StartX,StartY,Player.X,Player.Y) to find the distance.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Wed Mar 20, 2013 7:04 pm

Thanks pal!
B
3
Posts: 4
Reputation: 308


Return to How do I....?

Who is online

Users browsing this forum: fredriksthlm and 18 guests