Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/386825632661131264
deleted 56 characters in body; edited tags
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

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 waybetter way and want to implement a structure like above (the code) to emulate a map like this below.:


 

! NOTE: Can an editor post this picture: https://i.sstatic.net/hg3WH.png as my question depends on it.enter image description here

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 below.


 

! NOTE: Can an editor post this picture: https://i.sstatic.net/hg3WH.png as my question depends on it.

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:

enter image description here

Source Link

How to code a Game Grid in Java?

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 below.


! NOTE: Can an editor post this picture: https://i.sstatic.net/hg3WH.png as my question depends on it.