Im having trouble understanding your code… I feel like the Falling action and the Jumping are combined. I also have a state based collision system
touching GREEN isGrounded = true
touching blue isHitCeiling = true
so the player falls if isGrounded is false as soon as it turns true the player stop falling, and if isHitCeiling becomes true the player will immediately start falling.
float jumpSrartOne = 0; //this is the currrent Y of the player when on a platform. the Player stops falling when isGrounded = true
float jumpStartTwo = 0; //this is the current Y of the player then the player initializes a second jump
//these states change with collision between "floor" rectangles and the player.
boolean isGrounded; //True if player is on the ground
boolean isJumpOne; //True if player has jumped OR is no longer touching a "ground block"
boolean isJumpTwo; //True if player has jumped while in the air
boolean isFloating; //True if payer has jumped twice and presses jump again
boolean isHitCeiling; //True if player has touched a ceiling block
boolean jumpOneOut; //when true player cant initialize another single jump until grounded
boolean jupTwoOut; //when true player cant initialize another double jump until grounded
final float GRAVITY = 9.8;
final float SINGLE_JUMP_POWER = 10;
final float DOUBLE_JUMP_POWER = 5;
public void update(){
//this is called every frame
if(player.getY >= jumpStartOne+maxSingleJump){
jumpOneOut = true;
}
if(player.getY >= jumpStartTwo+maxDoubleJump){
jumpTwoOut = true;
}
if(isGrounded){
//do Nothing
}else if(isJumpOne && !jumpOneOut){
singleJump();
}else if(isJumpTwo && !jumpTwoOut){
doubleJump();
}else if(isFloating){
//float();
}else{
//fall();
}
}
public void jump(){
//called on jump key pressed
if(isGrounded){
isJumpOne = true;
}else if(isJumpOne){
isJumpTwo = true
}else if(isJumpTwo){
isFloating = true;
}else if(isFloating){
isFloating = false; //shuts off floating to free fall again
}
}
public void groundPlayer(){
//called when player touches a floor
isJumpOne = false;
isJumptwo = false;
isFloating = false;
isGrounded = true;
}
public void singleJump(){
//working on single jump logic
}
public void doubleJump(){
//working on double jump logic
}
public void float(){
//working on Float logic.
}
public void fall(){
//working on Fall logic
}
also fun fact my game takes a heavy influence from Vectorman for the sega genesis and My art style looks closer to the Scott Pilgrim game for the 360 Arcade. if you want to know what my inspiration was, and want to look em up.