How to make a character “jump” when leaving an up slope?

I have developed a game in Android using a tile-based system. I´ve implemented 22º, 45º and 67º up and down slopes and everything works (almost) perfect. The problem now is that, when the character gets to the end of an up slope, it justs falls until it finds the ground. I want it to perform some kind of parabola depending on the slope and its speed. I think it´s better explained in the picture:

I already have a function that determines whether or not the character is leaving the slope, I just want some ideas of how to achieve that kind of "jump" in some pseudo-code or explanation because I don't know how to start. Any help would be appreciated.

-
Make sure that your character maintains horizontal velocity when running off a cliff. A parabola is made by keeping constant horizontal velocity, and applying a constant downward acceleration for gravity. In your diagram on the left side it kind of looks like the horizontal velocity is getting zeroed out. – Nathan Reed May 27 '13 at 20:38
^ This should be an answer, not a comment, cause it's the solution to the problem. – Timotei May 28 '13 at 8:24

Let's diversify the situation in the game in different sections :

Section 1: Character reaches Slope.

Section 2 : Character leaves Slope.

Section 3: After leaving slope, character must jump and then fall down .

As Nathan suggested, for a parabolic fall down, you need to maintain a constant horizontal velocity for your character, so i am hoping you now have something like :

`final horizontalVel = '10';//units/sec`

As you have already mentioned, you have a function to determine , if the character is leaving the slope or not. Let us assume, you call a function named `jumpAndFall()` after the character leaves the slope and set a global boolean variable `jumpAvailable` to `true`.

So, here is a little algo for that :

```if(character_leaves_slope){ jumpAvailable = true; jumpAndFall(horizontalVel, jumpAvailable ); }```

Now inside the function :`jumpAndFall`:

You have got to calculate jump speed and add `gravity` to jump speed. However, your character's jumpSpeed must not exceed the game area length, so when it does, immediately reduce jump speed to make the character fall down, as obviously, we don't want your character to fly up!(Take that Newton, we can make the apple fly up :)) So, we will have :

``````jumpAndFall(String horizontalVel, boolean jumpAvailable ){

if(jumpAvailable )
jumpSpeed = horizontalVel + gravity;//Define gravity as normal gravity is defined.
if (jumpspeed>game.tileH-char.height) {
jumpspeed = game.tileH-char.height-2;//Can be any arbitrary value depending on how much you want the character to fall down
}
}
``````

I know this is not the exact code, but i hope this helps you in achieving what you are trying to do. In any case, i just laid out a little algorithm for you to think about.

Often for tile based games, i have found this site to be quite useful : Tile Game Programming.

-