Hello,
I'm trying to code a jump for my indie, but I'm having issues.
At first, I made a code that made the jump would be triangular. (meaning, jump -> reached max jump -> go down at same rate, it was visually like a triangle which I didn't like)
I want it to go as smooth as an hyperbole or demi-circle.
So I've changed the system used and implemented the following (C#):
public float updateJump(int j_state, float v_y)
{
float n = Math.Abs((float)Math.Sin(frametime * (Math.PI / 180d)) * JUMP_SPEED);
switch (j_state)
{
case 0: // Not Jumping
frametime = 0;
break;
case 1: // Jumping Up
v_y -= n;
v_jump += n;
break;
case 2: // Going Down
v_y += n;
v_jump -= n;
break;
}
if (v_jump < 0)
{
isjumping = false;
v_jump = 0;
}
frametime++;
return v_y;
}
The thing is that it's doing it instantaneously or not even doing it, not sure if it's because funcs calls are too fast or some code error.
Here's the full code:
http://pastebin.com/7wZHdSQh
Thanks in advance.