Ehh... It's really just a guess, but do you clear the screen?
Also, in the second for loop you should use
:
for (int y = 0; y < mapArray[x].length; y++) |
, else you could run into ArrayIndexOutOfBoundsExceptions (I like to call them aioobe

) if something is not that right...
And finally I'd do it different, but that's just me:
I would have initialization code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public void init() { Random rand = new Random();
for (int x = 0; x < mapArray.length; x++) { for (int y = 0; y < mapArray[x].length; y++) { int i = rand.nextInt(700); if (i == 700) mapArray[x][y] = WALL_ID; else if (i > 580) mapArray[x][y] = EARTH_ID; else if (i > 500) mapArray[x][y] = TREE_ID; else mapArray[x][y] = GRASS_ID; } } } |
And in the rendering I'd do this:
1 2 3 4 5 6 7 8 9 10
| for (int x = 0; x < mapArray.length; x++) { for (int y = 0; y < mapArray[x].length; y++) { switch (mapArray[x][y]) { case GRASS_ID: g.drawImage(grass, x * TILE_SIZE, y * TILE_SIZE); case TREE_ID: g.drawImage(tree, x * TILE_SIZE, y * TILE_SIZE); case EARTH_ID: g.drawImage(earth, x * TILE_SIZE, y * TILE_SIZE); case WALL_ID: g.drawImage(wall, x * TILE_SIZE, y * TILE_SIZE); } } } |
And the constants would be written at the top of the class of your choice:
1 2 3 4 5 6
| public static int GRASS_ID = 0; public static int TREE_ID = 1; public static int EARTH_ID = 2; public static int WALL_ID = 3;
public static int TILE_SIZE = 16; |
<edit>
But finally this doesn't help with your problem...

That's just me
