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

2016/4/30

moving actor one given location and go to another

1
2
NIRO17 NIRO17

2016/5/1

#
i am new to java and greenfoot so could you please send me the full code of obstacle avoiding, inside my zombie class..
NIRO17 NIRO17

2016/5/1

#
i typed like this..but its not working..
 public void moveAround(){
        if(sidestepping){
            move(1);
        }
        
        else{
        int speed = 2; 
        if (getOneIntersectingObject(Barrel.class) != null) move(-speed);
        if(Greenfoot.getRandomNumber(100)<10){
            turn(Greenfoot.getRandomNumber(180)-90);
        }}

    }

danpost danpost

2016/5/1

#
NIRO17 wrote...
in my zombie where i have to put this code??
The instance field goes within the class code, but outside any methods or constructors. The summary will have to be coded properly and placed in the act method or a method it calls.
danpost danpost

2016/5/1

#
The 'else' part is missing initial movement. The 'sidestepping' part needs to change the value of sidestepping back to false either unconditionally or conditionally. In the 'else' part when intersecting a barrel, you not only need to move back but a turn toward so open direction would be helpful.
NIRO17 NIRO17

2016/5/1

#
how can i correct this?
public void moveAround(){
       if(sidestepping){
           move(1);
       }
        
       else{
       int speed = 2; 
       if (getOneIntersectingObject(Barrel.class) != null) move(-speed);
       if(Greenfoot.getRandomNumber(100)<10){
           turn(Greenfoot.getRandomNumber(180)-90);
       }}
 
   }
NIRO17 NIRO17

2016/5/3

#
danpost, have you heard about multi agent technoly in Ai? can we use greenfoot gaming platform to develop a multi agent simiulator? can we apply JADE or MadKit like libaries to work with greenfoot?
danpost danpost

2016/5/3

#
NIRO17 wrote...
danpost, have you heard about multi agent technoly in Ai? can we use greenfoot gaming platform to develop a multi agent simiulator? can we apply JADE or MadKit like libaries to work with greenfoot?
You can use greenfoot to do pretty much anything you can do outside of greenfoot. The documentation for native libraries is here.
You need to login to post a reply.
1
2