Hey im making a game an i use hitpoints but if the hitpoints are 0 the world needs to change but i don't know how
this is my code for the enemy's:
this is my code for an enemy subclass:
and this is my code for the bullet:
Please help!
  {
    private boolean left = false;
    public int hitpoints;
    public int speed;
    public int jump;
    /**
     * Checks to see if the enemy is shot, if so then the enemy is removed from
     * the world
     */
    public void act() {
        if (getX() - getImage().getWidth() / 2 <= 1  ||
        getX() + getImage().getWidth() / 2 >= getWorld().getWidth()-1)
        {
            left = !left;
            setLocation( getX() , getY() +jump);
        }
        if(left)
        {
            move(-speed);
        }
        else {
            move(speed);
        }
        if(isTouching(Human.class)){
            removeTouching(Human.class);
            Greenfoot.setWorld(new Invaded());  
        }
        if(hitpoints <= 0)
        {
            getWorld().removeObject(this);
        }
    }// down is the pixels by which your enemy should come down    
}public class SpaceShip2 extends Enemy
{
   public SpaceShip2()
    {
        hitpoints = 1;
        speed = 5;
        jump = 50;
    }
}public void act() 
    {
        setLocation(getX(), getY() -10);
        if(getY() <= 20) 
        { 
            World SpaceWorld;
            SpaceWorld = getWorld();
            SpaceWorld.removeObject(this);
        }
        if ( getWorld() != null)
        {
            Enemy theEnemy;
            theEnemy = (Enemy) getOneIntersectingObject(Enemy.class);
            if (theEnemy != null)
            {
                SpaceWorld spaceWorld;  
                spaceWorld = (SpaceWorld) getWorld();      
                theEnemy.hitpoints--;
                Counter score = ((SpaceWorld)getWorld()).getScore(); 
                score.add(1);
                spaceWorld.removeObject(this);
                
            }
            
        }
    }
} 
          
         
   




