Hi,
I've attempted to code some gravity / jump code and it sort of works if everything is on one level:
How do I edit the groundLevel variable to accept offsets for different classes i.e. pipe, stepping tile, block? My scenario is located here: http://www.greenfoot.org/scenarios/15453
Thanks in advance
private void checkGravity()
{
int groundLevel = 520;
boolean onGround = (getY() == groundLevel);
if (!onGround)
{
ySpeed++;
setLocation(getX(), getY() + ySpeed);
if (getY() >= groundLevel)
{
setLocation(getX(), groundLevel);
}
}
else
{
if (Greenfoot.isKeyDown("up"))
{
ySpeed = -18;
setLocation(getX(), getY() + ySpeed);
}
}
}

