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

2018/3/5

Help

hosfeldli hosfeldli

2018/3/5

#
How would I make a method to see if a Survivor class is close to a Zombie, then if so have the Zombie class move towards the Survivor class? I know this is not how this is supposed to be used, but I just can't figure out how to do those 2 things.
danpost danpost

2018/3/5

#
The 'getObjectsInRange' method will let you know if any are in range (by getting the size of the list returned). Use it in the Zombie class to look for Survivor. Then, you can grab the first element from the list and turn toward its location coordinates.
hosfeldli hosfeldli

2018/3/5

#
I was trying to use get neighbor, thanks
danpost danpost

2018/3/5

#
hosfeldli wrote...
I was trying to use get neighbor, thanks
Yeah -- the 'getNeighbours' method is more suited for grid worlds (where the cell size is greater than a single pixel).
You need to login to post a reply.