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

2017/4/28

getNeighbours help.

Reny Reny

2017/4/28

#
So I'm trying to make a PACman game for my project. We were asked to use at least two "List" methods. I'm using "getNeighbours" to check if the ghost is near any walls, check which side is open and go that way. I have no idea how are you suppose to even use this, whether it checks top or left or right or bottom first, or how do you even tell the ghost to go to the way that's opening... All I have so far is List <Wall> wall = getNeighbours(1, false, Wall.class); So if anyone can give me any hints or tips? Thanks :)
danpost danpost

2017/4/28

#
The 'getNeighbours' method is more for gridded world (worlds that have a cell size greater than one where actors usually fit inside one cell). The 'getObjectsAtOffset' method might work a little better (in fact, you can use it four times to check on all four sides of the actor). If I read the instructions you gave correctly (presuming that the wording is correct), then you need to use at least two "List" methods (like 'get(int)', 'isEmpty()' and 'size()', to name a few methods that could be used).
You need to login to post a reply.