Hello again,
In my scenario my character dies when she reaches the bottom of the world.
WHat I would like to do it when she reaches the bottom of the world AND has 3,2 or 1 life, spawn het at the starting point.
This is what I have got.
My mover
My character
My score
Any ideas?
public class Mover extends Actor
{
public int vSpeed = 0;
public void setVSpeed(int speed)
{
vSpeed = speed;
}
public void fall()
{
setLocation ( getX(), getY() + vSpeed);
vSpeed = vSpeed + acceleration;
if ( atBottom())
gameEnd();
}
public boolean atBottom()
{
return getY() >= getWorld().getHeight() - 2;
}
public void gameEnd()
{
Greenfoot.setWorld(new gameOver());
}
}
public class Alice extends Mover
{
boolean onGround;
private void jump()
{
setVSpeed(-jumpStrength);
fall();
}
private void checkFall()
{
if (onGround()||onMover() || onUBlock()) {
setVSpeed(0);
}
else {
fall();
}
}
}
public class Score extends Counters
{
public Score()
{
updateImage();
}
/**
* Creates (or re-creates) the image of the object.
*/
private void updateImage()
{
setImage(new GreenfootImage("Life: ", 18, Color.black, new Color(0, 0, 0, 0)));
}
/**
* Adusts the score by <i>addAmt</i>.
*
* @param addAmt: the change in the score (negatives decrease the score)
*/
public void add(int addAmt)
{
Life+=addAmt;
updateImage();
}
}


