I've run across a very perturbing problem. I'm trying to create a "chunking" system for this little game I'm making. What I want to do right now is just generate infinite chunks of dirt blocks. It works right now, but I'm just using a two dimensional array, which stores the column and the index of the dirt. Here is the actual code:
public void generate(){
int newMax = dirtCount + dirtGeneratorChunk;
int oldCount = dirtCount;
for(int i = oldCount;i<newMax;i++){
dirt[dirtCount] = newDirt(spawnDirtX+column*16,
spawnDirtY,16,16,column,columnNumber);
columnNumber ++;
blockGrid[column][columnNumber] = spawnDirtY;
updateBlockGrid(column,(spawnDirtY-spawnDirtTop)/16,spawnDirtY);
dirtX[i] = spawnDirtX+column*16;
dirtY[i] = spawnDirtY;
hasDirt = true;
dirtCount ++;
spawnDirtY += 16;
if(spawnDirtY>500){
column++;
columnNumber = 0;
spawnDirtY = spawnDirtYOriginal;
}
}
repaint();
}
Hopefully that is helpful to show what I'm trying to do. As I'm sure you can tell by the code, I'm pretty new to Java and may be using bad practices/inefficient methods. If you have any suggestions on how I can improve my programming, I would love to hear them! Back to the point. Here is what I have so far on the ArrayList:
//Construct a new empty ArrayList for type int[][]
ArrayList<int[][]> chunkHolder = new ArrayList<int[][]>();
//Fill ArrayList (index, int[][])
chunkHolder.add(chunkCount, createBlockGrid());
chunkCount ++;
Object[] chunkArray = chunkHolder.toArray();
System.out.println(chunkArray[0]);
public static int[][] createBlockGrid(){
int[][] blockGrid = new int[64][256];
return blockGrid;
}
When I attempt to use System.out.println(chunkHolder.get(0));
, it returns: [[I@337838
. Obviously this isn't what I want... what am I doing wrong?
Thank you all for your help!
~Guad
(If I explained anything without clarity, please tell me!)