Itβs not easy to understand what you are trying to do ...
How do you encode the coordinates into this grassCoords array? As the current form, it has 5x5 elements.
int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } };
Since he has grass in his name, I assume that you want to draw only grass, then you can define it like this
int[][] grassCoords = new int[][] { {0, 0}, {16, 16}, {32, 32} };
Above each element, such as {0, 0} , there would be one coordinate for the grass tile.
The second problem is related to your loop, you do not read any data from grassCoords except the length of the arrays, and when you increase the index, you increase it with grass.getWidth() , which does not really make sense.
int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } }
You must mass iterate correctly and extract data from it.
int x = 0; for (x = 0; x < grassCoords.length; x++) { c.drawBitmap(grass, grassCoords[x][0], grassCoords[x][1], null); }
If I were you, I would at least once study the related parts of the Java tutorial .