When it is moving to right, x is increasing and to left it's decreasing.

Right.Now, when there are an event (here for example : when the caracter is colliding a box) the caracter jumps.The caracter jumps during 2 seconds on 300 pixel.

It is good for the x move.But i can't get the y.

The problem is to find the y from the x.

(i wish to be clear ?)

The initials coodinates can be everything, it is not important.

(ex (200;500))

On this exemple we can see 3 phases.

Before jump

During the jump

After the jump

Before the jump Y don't change and x has a fix velocity.During the jump y (i will find it one day ) and x adjust its velocity for the jump lenght (2 seconds)After jump, x and y return to their initials states

Thx for the reply Zendar =)

-----------------------------------------------------I am French, be indulgent with my written words please

Why not do it acceleration and velocity based? In other words, when he jumps, apply an impulse to his velocity, and constantly apply a downwards impulse from gravity. That is generally the best way to do things.

If you want to just make a parabola, that's generally pretty easy too. Just use a sine curve and it will look fairly natural if you tweak the curve you use. But it's never going to look as good as velocity-based jumping. Do that.

Oki i'll try it.But i think the result won't be a real beautifull parabola.I'll try it and i'll say you if the result is good.

Thx for answers.

It will indeed result in a parabola. The character's upward velocity is at its maximum when they first jump, and then is constantly decreased until it hits the minimum at the peak of the jump to become 0. Then the downward velocity is at its minimum just as it starts to drop and maximum once the ground is hit.

so say if you character started on the ground and at 100 pixels x value, and was currently at 110 pixels then the equation would be like this

y = -50/169(110 - 113)^2 + 50

having said all that I just want to add 2 things. first off, I may have made a mistake somewhere in here, so dont just follow it blindly. second off, eli 's(haha, I typed demonpants and erased cuase I remembered ur chaned name ) way is probably better because there isnt as much math involved, but if you want your perfect parabola this should give it to you.

additional note, parabol move like that is executed by one single press button such as jump. if you want the jump to be driven by arrow button, it'll be simpler. send your char to top with certain Dy as jump speed and time (or Y, choose one) as limit (max high). then return your char to ground with negative value of Dy (can be same or not to previous one). listen up to key event especially left and right buttons and update char's X value based on that. hope I make it clear.

well, you could instead of taking time or height, in order to make it a little more generic do what eli said, just add a constant negative value on y accelaration (or in reality it would be positive cause of coordinates).

so waht you could do is give the y acceleration a big boost at start of jump, and then during the loop just have a variable that is whether the character is off the ground (cause u can be off the ground without jump) and then add a line like thisif(!onGround) yacceleration-=1;

yeah, I used to use the height to know when to start falling, but it makes the jump constant because when you jump you really slow down until you reach the top of your jump, but if you just go up and then down, you are going to go the same speed the whole way.

You (OP) seem to look at this as if you're coming straight from your physics textbook which has focus on calculating airtime, maximum points, e.t.c of parabolas. You need to drop that, as it isn't applicable to games in a simple way. You need to start looking at how we solve physics problems with computers: With numerical integration. It's a scary word, but it only means that each iteration is based on the previous one, like the formula: y(n + 1) = y + dy. If you don't understand this formula, it basically means that the next value of y is equal to the current value plus the difference in y each frame.

What does this have to do with jumping? y is your y coordinate. dy is your change in y over time, equal to your velocity. You also have a ddy, also called dv (delta velocity), also called acceleration, also called gravity (har har).

I would implement it by having two different states for the player: on ground and in air. When he is on the ground he has a constant y, a velocity of 0 and an acceleration of 0 (gravity is countered by the surface he's standing on). When he is in air, he has a varying y value, a varying velocity and a constant acceleration. Each frame, you add the acceleration to your velocity, and then your velocity to your position. Finally you check for collisions.

To initiate a jump, when the player presses jump, check if you're currently on the ground. If you are, set state to in air, give the player a one time boost to velocity. The rest is handled by the above updating.

So sorry if I'm just repeating what everyone's been saying already... ._.

When he is on the ground he has a constant y, a velocity of 0 and an acceleration of 0 (gravity is countered by the surface he's standing on). When he is in air, he has a varying y value, a varying velocity and a constant acceleration. Each frame, you add the acceleration to your velocity, and then your velocity to your position. Finally you check for collisions.

I never said that I used parabolas for jumping.... I in fact explicitly said that was NOT the best way to do it. I do it like eli said. And how is the post you quoted show that I am being to complicated? I was just saying why having a constant velocity is a bad thing.

I'm just going to assume that everything after the first sentence wasn't directed at me, because lets be honest, if I didn't listen in math class would I really have been able to explain all I just did?

I never said that I used parabolas for jumping.... I in fact explicitly said that was NOT the best way to do it. I do it like eli said. And how is the post you quoted show that I am being to complicated? I was just saying why having a constant velocity is a bad thing.

I'm just going to assume that everything after the first sentence wasn't directed at me, because lets be honest, if I didn't listen in math class would I really have been able to explain all I just did?

Ah, sorry!! That was directed at OPs first post and the general impression I was getting of his posts after quickly eyeing through it! The math class thing was just a random "If you don't get what that means, here's an explanation."! Changed... T______T

EDIT: MY GOD!!! How could I possibly add quote from you, h3ckboy? I must have completely forgotten that I had your quote up there!!! T_________________________________T

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org