submitted by 9
submitted by 7
represented by 8
represented by 6
2d array -1 is empty area and 0 is full grass
this is the code i use to render the view
private int[][] terrain = new int[20][20];
}
protected Drawable[] tiles = new Drawable[10];
tiles[GameMap.GRASS] = getResources().getDrawable(R.drawable.grass);
tiles[GameMap.GRASS_WU] = getResources().getDrawable(R.drawable.grass_wu);
tiles[GameMap.GRASS_WD] = getResources().getDrawable(R.drawable.grass_wd);
tiles[GameMap.GRASS_EU] = getResources().getDrawable(R.drawable.grass_eu);
tiles[GameMap.GRASS_ED] = getResources().getDrawable(R.drawable.grass_ed);
protected void onDraw(Canvas canvas) {
for (int x=0;x<map.getWidthInTiles();x++) {
for (int y=0;y<map.getHeightInTiles();y++) {
if(map.getTerrain(x,y) != -1){
tiles[map.getTerrain(x,y)].setBounds(x*16,y*16,(x*16) + 16,(y*16) + 16);
if (map.getUnit(x,y) != 0) {
tiles[map.getUnit(x,y)].setBounds(x*16,y*16,(x*16) + 16,(y*16) + 16);
}
tiles[map.getTerrain(x, y)].draw(canvas);
tiles[map.getUnit(x, y)].draw(canvas);
}
}
}
}
}
Why does my view look like this and how to fix it? 
source
share