Hey, I was reading this tutorial and I got an error with some of the code (I would reply to the thread, but it is too old to reply to).
The code I’m using from the tutorial is:
private List<Entity>[][] grid = null;
private int rows, cols;
private int cellSize;
public Grid ( int mapWidth, int mapHeight, int cellSize)
{
this.cellSize = cellSize;
rows = (mapHeight + cellSize - 1) / cellSize;
cols = (mapWidth + cellSize - 1) / cellSize;
grid = new ArrayList<Entity>[cols][rows];
}
And I get this error “Cannot create a generic array of ArrayList”.
I am not sure why it seems to work in the thread, but not on my tests. Maybe it is something to do with the Java versions?
If this simply cannot be done, could you recommend a method for collision checking that runs fast (currently I’m using brute force, with around 100+ entities at a time).
Thanks! :3