Hello I'm trying to create physics for my platformer (jumping and gravity). But when I press (X) the player just swaps to the vertical height. So lets say when I press X the player's Y cordinate will decrease by 64 so it will jump into the air 64 pixels. But it does it all at once, I want it to slowly assend into the air 1 pixel at a time like in a real platformer. So basicly I wanted the player to continously assend untill it assended 64 pixels. I've tried implimenting it like this:

jumping is not something very difficult to add in a game
first, you have to include gravity. It will increase your Y speed, simulating a falling object
('sy' is your character Y speed)

Code PHP:

while(true){//game loopplayer->sy+=1;//adding the gravitytestCollisions();//testing the collisions so that you don't pass through the groundplayer->y+=player->sy;//setting new Y position}

Basically, this just makes your character falling until it hits the ground
when you're on the ground, you can jump !

Code PHP:

while(true){//game loopplayer->sy+=1;//adding the gravity testCollisions();//testing the collisions so that you don't pass through the ground

if(player->touchingGround && osl_keys->pressed.cross){//player on the ground and we press X : we can jump !player->sy = -20;//the player now has a negative speed : he will jump !}player->y+=player->sy;//setting new Y position}

Each loop will increase the Y speed (after a jump, or when the character falls)
- Y speed will start being negative : the character will "fly"
- each loop increases this speed : the character reduces its jump
- at some point, speed reaches 0 : character is at the highest point of its jump
- then it falls

basically, to make a character jumping, you just have to input a negative Y speed (whatever value does the trick. A higher negative one makes a higher jump) to your character and the gravity will do the rest

// If (X) is pressed and player is on the ground
if(osl_keys->pressed.cross && collisionMgr(mapCollision1,player,0,0,0,1))
{
player.sy = -20;
}
player->y += player.sy;
}

{......}

It does work my player does jump up and comes down
but it would get stuck in the tile when he'd come back down and if he is jumping and there is another tile above the player it would get stuck. I wasn't sure what would happen if my player comes back down so I set the speed to zero if thats not right please tell me.

EDIT: I think my collision system doesn't work well. What would be a good method of collision in this situation?