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

2012/7/19

getNeighbors

fishwaffles1337 fishwaffles1337

2012/7/19

#
I am trying to make something a long the lines of Conway's Game of Life and can perfectly visualize how I want to do it, but I can't figure out how to use the getNeighbor function and fail at reading Greenfoot's api. Can someone give an example of how to use the getNeighbors function?
davmac davmac

2012/7/19

#
What have you tried?
fishwaffles1337 fishwaffles1337

2012/7/19

#
I got that part to work
/**
     * Find out how many cells are next to the cell.
     */
    public int lookForCells()
    {
       List neighbors = getNeighbours (1, true, null);
       return neighbors.size();
        }

    /**
     * This is just a test chunk remove later.
     */
    public void testStuff()
    {
        if (neighbors.size() > 1){
        displayText();
      }
    }
davmac davmac

2012/7/19

#
Ok, so what part didn't work?
fishwaffles1337 fishwaffles1337

2012/7/19

#
Nothing now I fixed all the bugs I just need to find a way of making calls to the empty spaces in the grid.
fishwaffles1337 fishwaffles1337

2012/7/19

#
I've published the game feel to look at it and give any suggestions, it's obviously still a work in progress.http://www.greenfoot.org/scenarios/5708
You need to login to post a reply.