}Can Any one help figure out what is not working? I have two characters and they will not jump at different times. They will only jump at different times and I cant figure it out.
public int ySpeed= 0;
public void act()
{
int groundLevel = getWorld().getWidth() - getImage().getHeight()/2;
boolean onGround = (getY() == groundLevel);
if (!onGround) // in middle of jump
{
ySpeed++; // adds gravity effect
setLocation(getX(), getY()+ySpeed); // fall (rising slower or falling faster)
if (getY()>=groundLevel) // has landed (reached ground level)
{
setLocation(getX(), groundLevel); // set on ground
// clears any key pressed during jump
}
}
else // on ground
{
if ("w".equals(Greenfoot.getKey())) // jump key detected
{
ySpeed = -15; // add jump speed
setLocation(getX(), getY()+ySpeed); // leave ground
}
}
}

