This site requires JavaScript, please enable it in your browser!
Greenfoot back
KCee
KCee wrote ...

2023/3/27

Demon class killing villagers that are being grabbed

1
2
KCee KCee

2023/3/27

#
I have a actor called BloodDemon who chases after villagers and kills them. My problem is that actors that grab the villagers first before killing them are giving me errors because the blood demon will kill the villagers while they are grabbed. How do i fix this? Blood Demon code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList;

/**
 * The Ambulance subclass
 */
public class BloodDemon extends Vehicle
{
    
    private ArrayList <Villager> villagers;
    private Villager targetVillager;
    private int soulCount = 0;
    public BloodDemon(VehicleSpawner origin){
        super(origin); // call the superclass' constructor
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 200, image.getHeight() - 250);
        setImage(image);
        maxSpeed = 0.7;
        speed = maxSpeed;
        yOffset = 0;
        //enableStaticRotation();
    }

    /**
     * Act - do whatever the Ambulance wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        if (targetVillager != null && targetVillager.getWorld() != null)
        {
            moveTowardVillager();
            checkHitPedestrian();
        }
        else
        {
            targetClosestVillager();
            moveRandomly();
        }
        
        if (getX() <= 5 || getX() >= getWorld().getWidth() - 5)
        {
            turn(180);
        }
        
        if (getY() <= 5 || getY() >= getWorld().getWidth() - 5)
        {
            turn(180);
        }
        /*drive();
        checkHitPedestrian();
        if (checkEdge()){
            getWorld().removeObject(this);
        }*/
    }
    
    private void targetClosestVillager ()
    {
        double closestTargetDistance = 0;
        double distanceToActor;
        int numVil;
        // Get a list of all Villagers in the World, cast it to ArrayList
        // for easy management

        numVil = getWorld().getObjects(Villager.class).size();

        // If any villagers are found
        if (numVil > 50) // If lots of villagers are found, search small area
        {
            villagers = (ArrayList)getObjectsInRange(80, Villager.class);
        }
        else if (numVil > 20) // If less villagers are found, search wider radius
        {
            villagers= (ArrayList)getObjectsInRange(180, Villager.class);
        }
        else    // If even fewer villagers are found, search the whole World
            villagers = (ArrayList)getWorld().getObjects(Villager.class);

        if (villagers.size() > 0)
        {
            // set the first one as my target
            targetVillager = villagers.get(0);
            // Use method to get distance to target. This will be used
            // to check if any other targets are closer
            closestTargetDistance = VehicleWorld.getDistance (this, targetVillager);

            // Loop through the objects in the ArrayList to find the closest target
            for (Villager o : villagers)
            {
                // Cast for use in generic method
                //Actor a = (Actor) o;
                // Measure distance from me
                distanceToActor = VehicleWorld.getDistance(this, o);
                // If I find a villager closer than my current target, I will change
                // targets
                if (distanceToActor < closestTargetDistance)
                {
                    targetVillager = o;
                    closestTargetDistance = distanceToActor;
                }
            }
        }
    }
    
    private void moveRandomly()
    {
        if (Greenfoot.getRandomNumber (100) == 50)
        {
            turn (Greenfoot.getRandomNumber(360));
        }
        else
            drive();
    }
    
    private void moveTowardVillager()
    {
        turnTowards(targetVillager.getX(), targetVillager.getY());
        drive();
    }
    
    public boolean checkHitPedestrian () {
        Actor v = getOneIntersectingObject(Villager.class);
        
        if (v != null){
            getWorld().removeObject(v);
            soulCount+=1;
            return true;
        }
        return false;
    }
    
    private void explode()
    {
        if (soulCount >= 20)
        {
            
        }
    }
}
Grabber code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Grabber here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public abstract class Grabber extends Vehicle {
    private Villager grabbed;
     
    public Grabber(final VehicleSpawner origin) {
        super(origin);
    }
  
    public void act() {
        drive();
        checkHitPedestrian();
    }
     
    public boolean checkHitPedestrian() {
        final boolean isNewlyGrabbed = tryGrab();
        if (grabbed != null) 
        {
            if (grabbed.getWorld() == null) 
            {
                grabbed = null;
            } 
            else 
            {
                actionWithGrabbed(grabbed, isNewlyGrabbed);
            }
        }
        return grabbed != null;
    }
    
    public Villager getGrabbed() 
    {
        return grabbed;
    }
    
    private boolean tryGrab() 
    {
        if (grabbed == null) {
            final VehicleWorld world = (VehicleWorld)getWorld();
            for (final Villager villager : getObjectsAtOffset((int)speed + getImage().getWidth() / 2, 0, Villager.class)) {
                if (!world.isGrabbed(villager)) {
                    grabbed = villager;
                    return true;
                }
            }
        }
        return false;
    }
     
    /**
     * Do whatever has to be done with the grabbed villager.
     * 
     * This method is automatically called after checkHitPedestrian has grabbed onto a villager.
     * 
     * @param grabbed the grabbed villager, must not be null.
     * @param isNewlyGrabbed whether the villager has just been grabbed in this act.
     */
    protected abstract void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed);
     
    public void releaseGrabbed() {
        grabbed = null;
    }
}
envxity envxity

2023/3/27

#
try setting the villager grabbed to a boolean and if they have a villager grabbed it would be true so then sett it where like this
if(villagerGrabed = true){
      move(x); // moves the demon x amount of spaces away
      releaseVillager(); 
      killVillager();

}
btw i lover our game idea is it like a demon slayer based game?
KCee KCee

2023/3/27

#
i dont want the demon to take the villager if its already grabbed, i just want it to either ignore it or do nothing upon contact with the villager. Also nah its not based on demon slayer its just a simulation im making with the concept of monsters and witches
Spock47 Spock47

2023/3/27

#
Check the isGrabbed method before eating (in BloodDemon):
        public boolean checkHitPedestrian () {
            final VehicleWorld world = (VehicleWorld)getWorld();
            for (final Villager villager : getIntersectingObjects(Villager.class)) {
                if (!world.isGrabbed(villager)) {
                    world.removeObject(villager);
                    soulCount+=1;
                    return true;
                }
            }
            return false;
        }
KCee KCee

2023/3/28

#
Thanks! new issue im pretty sure you helped me fix this in the past but for some reason the actors under the grabber class are starting to grab villagers when they are already being grabbed by another monster again Grabber code for reference:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Grabber here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public abstract class Grabber extends Vehicle {
    private Villager grabbed;
     
    public Grabber(final VehicleSpawner origin) {
        super(origin);
    }
  
    public void act() {
        drive();
        checkHitPedestrian();
    }
     
    public boolean checkHitPedestrian() {
        final boolean isNewlyGrabbed = tryGrab();
        if (grabbed != null) 
        {
            if (grabbed.getWorld() == null) 
            {
                grabbed = null;
            } 
            else 
            {
                actionWithGrabbed(grabbed, isNewlyGrabbed);
            }
        }
        return grabbed != null;
    }
    
    public Villager getGrabbed() 
    {
        return grabbed;
    }
    
    private boolean tryGrab() 
    {
        if (grabbed == null) {
            final VehicleWorld world = (VehicleWorld)getWorld();
            for (final Villager villager : getObjectsAtOffset((int)speed + getImage().getWidth() / 2, 0, Villager.class)) {
                if (!world.isGrabbed(villager)) {
                    grabbed = villager;
                    return true;
                }
            }
        }
        return false;
    }
     
    /**
     * Do whatever has to be done with the grabbed villager.
     * 
     * This method is automatically called after checkHitPedestrian has grabbed onto a villager.
     * 
     * @param grabbed the grabbed villager, must not be null.
     * @param isNewlyGrabbed whether the villager has just been grabbed in this act.
     */
    protected abstract void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed);
     
    public void releaseGrabbed() {
        grabbed = null;
    }
}
Spock47 Spock47

2023/3/28

#
Maybe a subclass overrides the checkHitPedestrian method? Try to change line 21 of Grabber to
public final boolean checkHitPedestrian() {
If an error shows up in any subclass, we found the problem. There, replace the override of checkHitPedestrian with an override of actionWithGrabbed:
@Override
protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
    // do whatever has to be done with the gabbed villager.
}
KCee KCee

2023/3/28

#
Thanks that worked! could you also try to answer my question in the other discussion post about the ySpeed variable?
KCee KCee

2023/3/28

#
Spock47 wrote...
Maybe a subclass overrides the checkHitPedestrian method? Try to change line 21 of Grabber to
public final boolean checkHitPedestrian() {
If an error shows up in any subclass, we found the problem. There, replace the override of checkHitPedestrian with an override of actionWithGrabbed:
@Override
protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
    // do whatever has to be done with the gabbed villager.
}
After i did this my Acidmon actor now does what my Prowler actor is supposed to do, which is grab them and run off screen. Acidmon code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Acidmon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Acidmon extends Grabber
{
    private Actor grabbed;
    int timer = 0;
    private GreenfootSound crunchSound;
    public Acidmon(VehicleSpawner origin) {
        super(origin); // call the superclass' constructor
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 120, image.getHeight() - 350);
        setImage(image);
        maxSpeed = 1.5 + ((Math.random() * 30)/5);
        speed = maxSpeed;
        yOffset = 0;
        crunchSound = new GreenfootSound ("crunching.wav");
    }
    
    public void act()
    {
        if (timer == 0) 
        {
            drive();
        } 
        checkHitPedestrian();
    }
    
    protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
        if (isNewlyGrabbed) {
            turn(Greenfoot.getRandomNumber(360));
        }
        grabbed.setLocation(getX() + 30, getY());//adjust '30' value as needed
        if (grabbed.isAtEdge()) {
            getWorld().removeObject(grabbed);
            releaseGrabbed();
        }
    }
    
    public boolean actionWithGrabbed()
    {
        if (grabbed == null) 
        {
            grabbed = getOneObjectAtOffset((int)speed + getImage().getWidth()/2, 0, Villager.class);
            if (grabbed != null) 
            {
                timer = 120; // starting timer when grabbing pedestrian
                crunchSound.setVolume(80);
                crunchSound.play();
            }
        }
        
        if (grabbed == null || timer == 0) 
        {
            return false; // both these conditions mean the same thing;
            // either one could be removed without changing anything;
            // both used for conciseness of code (preventing any possible errors in lines to come)
        }
        
        if (grabbed.getWorld() != null)
        {
            grabbed.setLocation(getX()+15, getY()); // again conditioned to avoid any possible error
        }
        
        if (--timer == 0) { // running timer and checking time expired
            getWorld().addObject(new PoisonCloud(), grabbed.getX(), grabbed.getY());
            getWorld().removeObject(grabbed);
            grabbed = null;
        }
        return grabbed != null; // or:  return timer > 0;
    }
}
Prowler code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Prowler here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Prowler extends Grabber {
    public Prowler(VehicleSpawner origin) {
        super(origin); // call the superclass' constructor
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 200, image.getHeight() - 200);
        setImage(image);
        maxSpeed = 1.5 + ((Math.random() * 30)/5);
        speed = maxSpeed;
        yOffset = 0;
    }
     
    protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
        if (isNewlyGrabbed) {
            turn(Greenfoot.getRandomNumber(360));
        }
        grabbed.setLocation(getX() + 30, getY());//adjust '30' value as needed
        if (grabbed.isAtEdge()) {
            getWorld().removeObject(grabbed);
            releaseGrabbed();
        }
    }
}
Grabber code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Grabber here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public abstract class Grabber extends Vehicle {
    private Villager grabbed;
     
    public Grabber(final VehicleSpawner origin) {
        super(origin);
    }
  
    public void act() {
        drive();
        checkHitPedestrian();
    }
     
    public final boolean checkHitPedestrian() {
        final boolean isNewlyGrabbed = tryGrab();
        if (grabbed != null) 
        {
            if (grabbed.getWorld() == null) 
            {
                grabbed = null;
            } 
            else 
            {
                actionWithGrabbed(grabbed, isNewlyGrabbed);
            }
        }
        return grabbed != null;
    }
    
    public Villager getGrabbed() 
    {
        return grabbed;
    }
    
    private boolean tryGrab() 
    {
        if (grabbed == null) {
            final VehicleWorld world = (VehicleWorld)getWorld();
            for (final Villager villager : getObjectsAtOffset((int)speed + getImage().getWidth() / 2, 0, Villager.class)) {
                if (!world.isGrabbed(villager)) {
                    grabbed = villager;
                    return true;
                }
            }
        }
        return false;
    }
     
    /**
     * Do whatever has to be done with the grabbed villager.
     * 
     * This method is automatically called after checkHitPedestrian has grabbed onto a villager.
     * 
     * @param grabbed the grabbed villager, must not be null.
     * @param isNewlyGrabbed whether the villager has just been grabbed in this act.
     */
    protected abstract void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed);
     
    public void releaseGrabbed() {
        grabbed = null;
    }
}
KCee KCee

2023/3/28

#
also my good witch and bad witches are now trying to frog and unfrog the poison clouds which is giving me ClassCastException errors... good witch code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class GoodWitch here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class GoodWitch extends Pedestrian
{
    
    public GoodWitch(int dir)
    {
        super(dir);
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 250, image.getHeight() - 300);
        setImage(image);
    }
    
    /**
     * Act - do whatever the Villager wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        checkHitVillager();
        move();
    }
    
    public boolean checkHitVillager () {
        Villager v = (Villager)getOneIntersectingObject(Villager.class);
        if (v != null){
            v.unfrogged();
            return true;
        }
        return false;
    }
}
evil witch code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class EvilWitch here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class EvilWitch extends Pedestrian
{
    public EvilWitch(int dir)
    {
        super(dir);
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 280, image.getHeight() - 290);
        setImage(image);
    }
    
    /**
     * Act - do whatever the Villager wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        checkHitVillager();
        move();
        
    }
    
    public boolean checkHitVillager () {
        Villager v = (Villager)getOneIntersectingObject(Villager.class);
        if (v != null){
            v.frogged();
            return true;
        }
        return false;
    }
}
poison cloud code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class PoisonCloud here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class PoisonCloud extends Actor
{

    /**
     * Act - do whatever the PoisonCloud wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public PoisonCloud ()
    {
        this.getImage().setTransparency(250);
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 150, image.getHeight() - 120);
        setImage(image);
    }
    
    public void act()
    {
        this.getImage().setTransparency(getImage().getTransparency() - 1);
        for (final Pedestrian touched : getIntersectingObjects(Pedestrian.class)) 
        {
            final Villager villager = (Villager)touched;
            if (((VehicleWorld)getWorld()).isGrabbed(villager))
            {
                continue;
            }
            getWorld().removeObject(touched);
        }
        
        if (this.getImage().getTransparency() < 5)
        {
            getWorld().removeObject(this);
        }
    }
}
Spock47 Spock47

2023/3/28

#
KCee wrote...
After i did this my Acidmon actor now does what my Prowler actor is supposed to do, which is grab them and run off screen.
Remove lines 35 to 45 and replace everything after that with this (this code is the only necessary code after act method):
    protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
        if (isNewlyGrabbed) {
            timer = 120; // starting timer when grabbing pedestrian
            crunchSound.setVolume(80);
            crunchSound.play();
        }
         
        if (grabbed.getWorld() != null) {
            grabbed.setLocation(getX()+15, getY()); // again conditioned to avoid any possible error
        }
         
        if (--timer == 0) { // running timer and checking time expired
            getWorld().addObject(new PoisonCloud(), grabbed.getX(), grabbed.getY());
            getWorld().removeObject(grabbed);
            releaseGrabbed();
        }
    }
Spock47 Spock47

2023/3/28

#
KCee wrote...
also my good witch and bad witches are now trying to frog and unfrog the poison clouds which is giving me ClassCastException errors...
Please show the error message (show whole stacktrace).
KCee KCee

2023/3/28

#
im not really sure what you mean by stacktrace but this is what it says: java.lang.IllegalStateException: Actor has been removed from the world. at greenfoot.Actor.failIfNotInWorld(Actor.java:722) at greenfoot.Actor.getX(Actor.java:169) at Acidmon.actionWithGrabbed(Acidmon.java:71) at Acidmon.act(Acidmon.java:31) at greenfoot.core.Simulation.actActor(Simulation.java:567) at greenfoot.core.Simulation.runOneLoop(Simulation.java:530) at greenfoot.core.Simulation.runContent(Simulation.java:193) at greenfoot.core.Simulation.run(Simulation.java:183) Caused by: greenfoot.ActorRemovedFromWorld at greenfoot.World.removeObject(World.java:466) at BloodDemon.checkHitPedestrian(BloodDemon.java:125) at BloodDemon.act(BloodDemon.java:33) ... 4 more java.lang.ClassCastException: class GoodWitch cannot be cast to class Villager (GoodWitch and Villager are in unnamed module of loader java.net.URLClassLoader @786b6cc9) at PoisonCloud.act(PoisonCloud.java:29) at greenfoot.core.Simulation.actActor(Simulation.java:567) at greenfoot.core.Simulation.runOneLoop(Simulation.java:530) at greenfoot.core.Simulation.runContent(Simulation.java:193) at greenfoot.core.Simulation.run(Simulation.java:183)
KCee KCee

2023/3/28

#
sorry for the overload of questions i gotta finish this by 12 so im stressing out a bit
KCee KCee

2023/3/28

#
also my demon seems to be killing the grabbed villagers again demon code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList;

/**
 * The Ambulance subclass
 */
public class BloodDemon extends Vehicle
{
    private GreenfootImage image;
    private ArrayList <Villager> villagers;
    private Villager targetVillager;
    private int soulCount = 0;
    public BloodDemon(VehicleSpawner origin){
        super(origin); // call the superclass' constructor
        GreenfootImage image = getImage();
        image.scale(image.getWidth() - 200, image.getHeight() - 250);
        setImage(image);
        maxSpeed = 0.7;
        speed = maxSpeed;
        yOffset = 0;
        //enableStaticRotation();
    }

    /**
     * Act - do whatever the Ambulance wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        if (targetVillager != null && targetVillager.getWorld() != null)
        {
            moveTowardVillager();
            checkHitPedestrian();
        }
        else
        {
            targetClosestVillager();
            moveRandomly();
        }
        
        if (getX() <= 5 || getX() >= getWorld().getWidth() - 5)
        {
            turn(180);
        }
        
        if (getY() <= 5 || getY() >= getWorld().getWidth() - 5)
        {
            turn(180);
        }
        /*drive();
        checkHitPedestrian();
        if (checkEdge()){
            getWorld().removeObject(this);
        }*/
    }
    
    private void targetClosestVillager ()
    {
        double closestTargetDistance = 0;
        double distanceToActor;
        int numVil;
        // Get a list of all Villagers in the World, cast it to ArrayList
        // for easy management

        numVil = getWorld().getObjects(Villager.class).size();

        // If any villagers are found
        if (numVil > 50) // If lots of villagers are found, search small area
        {
            villagers = (ArrayList)getObjectsInRange(80, Villager.class);
        }
        else if (numVil > 20) // If less villagers are found, search wider radius
        {
            villagers= (ArrayList)getObjectsInRange(180, Villager.class);
        }
        else    // If even fewer villagers are found, search the whole World
            villagers = (ArrayList)getWorld().getObjects(Villager.class);

        if (villagers.size() > 0)
        {
            // set the first one as my target
            targetVillager = villagers.get(0);
            // Use method to get distance to target. This will be used
            // to check if any other targets are closer
            closestTargetDistance = VehicleWorld.getDistance (this, targetVillager);

            // Loop through the objects in the ArrayList to find the closest target
            for (Villager o : villagers)
            {
                // Cast for use in generic method
                //Actor a = (Actor) o;
                // Measure distance from me
                distanceToActor = VehicleWorld.getDistance(this, o);
                // If I find a villager closer than my current target, I will change
                // targets
                if (distanceToActor < closestTargetDistance)
                {
                    targetVillager = o;
                    closestTargetDistance = distanceToActor;
                }
            }
        }
    }
    
    private void moveRandomly()
    {
        if (Greenfoot.getRandomNumber (100) == 50)
        {
            turn (Greenfoot.getRandomNumber(360));
        }
        else
            drive();
    }
    
    private void moveTowardVillager()
    {
        turnTowards(targetVillager.getX(), targetVillager.getY());
        drive();
    }
    
    public boolean checkHitPedestrian () 
    {
        final VehicleWorld world = (VehicleWorld)getWorld();
        for (final Villager villager : getIntersectingObjects(Villager.class)) 
        {
            if (!world.isGrabbed(villager)) {
                world.removeObject(villager);
                soulCount+=1;
                return true;
            }
        }
        return false;
    }
        
    private void explode()
    {
        if (soulCount >= 20)
        {
            image = new GreenfootImage("blood.png");
            image.scale(image.getWidth() - 100, image.getHeight() - 100);
            setImage(image);
        }
    }
}
KCee KCee

2023/3/28

#
Spock47 wrote...
KCee wrote...
After i did this my Acidmon actor now does what my Prowler actor is supposed to do, which is grab them and run off screen.
Remove lines 35 to 45 and replace everything after that with this (this code is the only necessary code after act method):
    protected void actionWithGrabbed(final Villager grabbed, final boolean isNewlyGrabbed) {
        if (isNewlyGrabbed) {
            timer = 120; // starting timer when grabbing pedestrian
            crunchSound.setVolume(80);
            crunchSound.play();
        }
         
        if (grabbed.getWorld() != null) {
            grabbed.setLocation(getX()+15, getY()); // again conditioned to avoid any possible error
        }
         
        if (--timer == 0) { // running timer and checking time expired
            getWorld().addObject(new PoisonCloud(), grabbed.getX(), grabbed.getY());
            getWorld().removeObject(grabbed);
            releaseGrabbed();
        }
    }
After doing this when i try to call the method here:
public void act()
    {
        if (timer == 0) 
        {
            drive();
        } 
        actionWithGrabbed();
    }
it tells me the method cannot be applied to given types (required: villager, boolean) (found: no arguments)
There are more replies on the next page.
1
2