Suppose I wanted to code a game grid in java. Not an abstract text one but an actual grid with graphics and 'cells'. Would I have to draw line by line or is there a more efficient way? Also how would I go moving units (objects) around the grid, moving them and repainting their positions?
public static int [] [] map = {{2,0,1,0,0}, // e.g. 2 is base
{1,0,0,0,0},
{0,0,0,0,0}, //1 is unit
{0,0,0,0,0},
{0,0,0,0,2}};
I still wonder if there is a resemblance between 2D arrays and actual game grids as I can just paint coordinates and lines. However I feel there is a better way and want to implement a structure like above (the code) to emulate a map like this: