![]() ![]() SetLocation(getX(), getY() + 1) //Here the figure is placed back on the stone.Įlse FallSpeed += Gravity //When in the air, the FallSpeed accelerates with gravity, each time the act method is executed. While(onSolidGround())// method prevents the figure from being on a stone or the ground by corralling the figure upwards until the figure is in the air. simulation physics friction greenfoot collisions projectilemotion simpleharmonicmotion. ![]() If(onSolidGround())// If on a solid block (stone or ground) the figure should not fall anymore SetLocation(getX(),getY() + FallSpeed) // When falling X stays the same only Y changes with FallSpeed GetOneObjectAtOffset(figureWidth / 2, figureHeight / 2, Stein.class) !=null) //When the figure touches the stone with the lower right or left edge, onStone is set true If(getOneObjectAtOffset(figureWidth / -2, figureHeight / 2, Stein.class) !=null || For this, you determine what the possible collision partners are for each. Int figureHeight = getImage().getHeight() also available in other game libraries, particularly Greenfoot more. rotation, changes of appearance, collision detection, etc. Public boolean onStone() //query whether figure is on a stone Greenfoot is an integrated development environment using Java or Stride designed primarily. Public boolean onSolidGround() //query whether figure is on a block(see below) or on the ground. It offers methods to easily program these actors, including method for movement, collision detection, changes of appearance and rotation. A better way is to create one object called Obstacle or Barrier but, and this is the neat thing, make it. Public FigurEng(int width, int height) //image scaling You apparently do have some collision detection working (for Walls and Wall2 objects) though that is not the easiest way to go about it (copying the same image over the top of itself, to get Actors to be detected). Installing Greenfoot Greenfoot API Collision detection Some Java details 163 165 169 175. * Write a description of class FigurEng here. ![]()
0 Comments
Leave a Reply. |