I am making a game in which I want the actor to jump can anyone help please.
// with instance field
int vspeed = 0;
// move vertically (rise or fall)
vspeed++; // increase speed due to gravity
setLocation(getX(), getY()+vspeed); // move vertically
// check for obstacle or edge and jumping
if (intersecting(whatever) || atEdge())
{
setLocation(wherever); // place actor above or below obstacle or edge as appropriate
vspeed = 0; // stop vertical movement
if (Greenfoot.isKeyDown("up") &&
hasObstacleOrEdgeBelow())
vspeed = -10; // adjust as needed (for jump start)
}// with instance field
int vspeed = 0;
// move vertically (rise or fall)
vspeed++; // increase speed due to gravity
setLocation(getX(), getY()+vspeed); // move vertically
// check for edge and jumping
if (atEdge())
{
setLocation(wherever); // adjust location of actor
vspeed = 0; // stop vertical movement
if (Greenfoot.isKeyDown("up"))
vspeed = -10; // adjust as needed (for jump start)
}