Grid World Java help
Ok, i dont know how many people are familiar with the new AP Comp. Sci. case study, but it is Grid World. Currently, I am making an actor called bombFlower. Guess wat it does? After 3 turns it is supposed to "explode" and get rid of every actor in a one block radius.
Like this:
to
But instead, i just receive a "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at bombFlower.act(bombFlower.java:16)"
heres the code:
[PHP]import info.gridworld.actor.*;
import info.gridworld.grid.*;
import java.util.ArrayList;
public class bombFlower extends Flower
{ private int timer;
private Grid<Actor> grid = getGrid();
public bombFlower()
{ setColor(null);
}
public void act()
{ Location loc = getLocation();
System.out.println(loc.toString());
timer++;
if(timer == 3)
{ ArrayList<Location> array = new ArrayList<Location>();
array = (grid.getOccupiedAdjacentLocations(loc));
for(int x = 0; x < array.size(); x++)
grid.get(array.get(x)).removeSelfFromGrid();
}
[/PHP]
Can someone please help me out or at least point me in the correct direction?
Like this:
to
But instead, i just receive a "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at bombFlower.act(bombFlower.java:16)"
heres the code:
[PHP]import info.gridworld.actor.*;
import info.gridworld.grid.*;
import java.util.ArrayList;
public class bombFlower extends Flower
{ private int timer;
private Grid<Actor> grid = getGrid();
public bombFlower()
{ setColor(null);
}
public void act()
{ Location loc = getLocation();
System.out.println(loc.toString());
timer++;
if(timer == 3)
{ ArrayList<Location> array = new ArrayList<Location>();
array = (grid.getOccupiedAdjacentLocations(loc));
for(int x = 0; x < array.size(); x++)
grid.get(array.get(x)).removeSelfFromGrid();
}
[/PHP]
Can someone please help me out or at least point me in the correct direction?
0
Comments
Anyway, let me see if I can figure out what you're trying to do. This seems almost like the fish just not as complex. Hell, I got bored last year and decompiled the jar files and changed out a couple images . Would you mind zipping the entire project because looking at just one class and a couple methods isn't really helping me. Are you just now starting the case study?
btw, getOccupiedAdjacentLocations(); is one hell of a long method name :/ I can't imagine I'd want to type that very often, but I guess it's up to you. I might has settled for something such as getAdj(); or even getAdjLocs(); Shorthand is your friend
also, if you want the pdf's that explain some of it, go here