I am trying to add caves to my tile based game but am having issues with the tiles not using the image when they are created.
Here is my code:
w = rand(10);
for (int wi = 0; wi <= w; wi++) {
h = rand(10);
for (int hi = 0; hi <= h; hi++) {
if (i - w >= 1 && j - h >= 1) {
map[i - w][j - h] = new tile(
tiles.yellow, i * size, j
* size, false);
if (h != 0) {
h--;
}
}
}
if (w != 0) {
w--;
}
}
Integer i is equal to the X coordinate of the tile.
Integer j is equal to the Y coordinate of the tile.
Here is the result of this:
What I was hoping for was for the grey areas to hold the tiles which are yellow and for the yellow tiles to not show up anywhere else. (I am only using this tile for testing)
If you know how I can correct this then please reply!
Thanks in advance!
I'm completely confused by your code, but should not it be
map[i - w][j - h] = new tile(tiles.yellow, (i - w) * size, (j - h) * size, false);
Otherwise I'm completely at loss what you are trying to do here?