[Solved] Tiling in Java

It’s when tou try to access a part of an array that is outside the limits.

Either less than zero, or more than the size of the array will give this.

I found the mistake:


for(int x = 0; x tiles.length; x++)
{
    for(int y = 0; y < tiles[x].length; x++)
    {
    // rendering code
    }
}

Notice how you increment x in the y loop. There is the problem.

OMG! I can’t believe I missed that, Thanks a ton, HeroesGraveDev

it works! success! Thank you all so much, its flipped to one side, i’ve tried iterating the y first and then x but that doesn’t seem to work neither does swapping the

tiles[x][y]

to

tiles[y][x]

.

i could work around it, but if others come looking for help with the same problem then it would probably be better to show them the complete code.

thanks everyone for the help!

Ignore the last post, I fixed it!

public void renderTiles(Graphics2D g) {
	   // Iterate through all tiles:
		for (int y = 0; y < tiles.length; y++) {
		      for (int x = 0; x < tiles[y].length; x++) {
	         renderTile(x, y, tiles[y][x], g);
	      }
	   }
	}

Thanks to matheus, HeroesGraveDev, Phibedy and SHC, i’ll edit the first post to show others what needs to be done for this tiling!
Thanks again
~Scyth