I’ve scoured via the web to discover a answer of this however that is the one answer that I may discover but it surely cancels the “yMove += jumpingVelocity * deltatime” as quickly as collision shouldn’t be detected anymore thus it immediately simply goes down. If I take away the isJumping the character continues to go up so long as the soar button is pressed.
xMove = 0;
yMove = 0;
if (handler.getKeyManager().left) xMove -= movementVelocity * deltaTime;
if (handler.getKeyManager().proper) xMove += movementVelocity * deltaTime;
if (handler.getKeyManager().soar && onFloor && !isJumping) {
yMove += jumpingVelocity * deltaTime;
isJumping = true;
}
else{
isJumping = false;
}
// gravity
yMove += gravity * deltaTime;
edit:
That is the code that updates the participant place
public void moveX(){
if (xMove > 0){
int tx = (int) (x + xMove + bounds.x + bounds.width) / Tile.TILEWIDTH;
if (!collisionWithTile(tx,(int) (y + bounds.y) / Tile.TILEHEIGHT) && !collisionWithTile(tx,(int) (y + bounds.y + bounds.top) / Tile.TILEHEIGHT) && tx < handler.getWorld().getWidth()){
x += xMove;
}
else{
x = tx * Tile.TILEWIDTH - bounds.x - bounds.width - 1;
}
}
else if (xMove < 0){
int tx = (int) (x + xMove + bounds.x) / Tile.TILEWIDTH;
if (!collisionWithTile(tx,(int) (y + bounds.y) / Tile.TILEHEIGHT) && !collisionWithTile(tx,(int) (y + bounds.y + bounds.top) / Tile.TILEHEIGHT)){
x += xMove;
}
else{
x = tx * Tile.TILEWIDTH + Tile.TILEWIDTH - bounds.x;
}
}
}
public void moveY(){
if (yMove < 0){
int ty = (int) (y + yMove + bounds.y) / Tile.TILEWIDTH;
if (!collisionWithTile((int) (x + bounds.x) / Tile.TILEWIDTH, ty) && !collisionWithTile((int) (x + bounds.x + bounds.width) / Tile.TILEWIDTH, ty)){
y += yMove;
}
else{
y = ty * Tile.TILEHEIGHT + Tile.TILEHEIGHT - bounds.y;
}
}
else if (yMove > 0){
int ty = (int) (y + yMove + bounds.y + bounds.top) / Tile.TILEWIDTH;
if (!collisionWithTile((int) (x + bounds.x) / Tile.TILEWIDTH, ty) && !collisionWithTile((int) (x + bounds.x + bounds.width) / Tile.TILEWIDTH, ty)){
y += yMove;
onFloor = false;
}
else {
y = ty * Tile.TILEHEIGHT - bounds.y - bounds.top - 1;
onFloor = true;
}
}
}