# Coordinates

• 09-05-2010, 02:52 PM
Witik
Coordinates
Hello,

I'm making a game with map tiles, and I need help specifying the coordinates.

I was using a method witch only colored rectangles, but I Switched to Images.

Inside the "public void paint(Graphics2D g)"
Code:

```                                  //Set the tile to grass                                 Tile = Grass;                                 if (data[x][y] == BLOCKED) {                                 //If it's BLOCKED, draw Rock                                 Tile = Rock;                                 }                                 g.drawImage(Tile, null, null);```
How I draw the map:
Inside the "public Map()"
Code:

```                for (int y=0;y<HEIGHT;y++) {                         data[0][y] = BLOCKED;                         data[WIDTH-1][y] = BLOCKED;                 }                 for (int x=0;x<WIDTH;x++) {                         data[x][0] = BLOCKED;                         data[x][HEIGHT-1] = BLOCKED;                 }                 data[3][2] = BLOCKED;                 data[3][3] = BLOCKED;                 data[3][4] = BLOCKED;                 data[4][3] = BLOCKED;                 data[5][2] = BLOCKED;                 data[5][3] = BLOCKED;                 data[5][4] = BLOCKED;```
and the data is
Code:

`        private int[][] data = new int[WIDTH][HEIGHT];`
when I run it, all I get is a tile on 0,0
• 09-05-2010, 03:04 PM
Fubarable
Perhaps it's me, but I can't get a handle on what you're trying to do or what problems you are having based on the information you've presented, as if you assume we know more about the inner workings of your program than we actually do (which is zilch). Please have a look at this link: How to ask Smart Questions.

Even though the title is somewhat condescending, it does provide many useful tips on how to provide enough information so that your question can be answered well. I know that the link has helped me out many times.

Luck!
• 09-05-2010, 03:16 PM
Fubarable
Also, this confuses me:
Code:

`g.drawImage(Tile, null, null);`
since every Graphics#drawImage(...) overload has ints for the 2nd and 3rd parameters.

Again, much luck!
• 09-06-2010, 07:05 AM
DarrylBurke
Quote:

Originally Posted by Fubarable
Also, this confuses me:
Code:

`g.drawImage(Tile, null, null);`
since every Graphics#drawImage(...) overload has ints for the 2nd and 3rd parameters.

Since the graphics reference is of type Graphics2D, the compiler would map that to
Code:

`drawImage(Image img, AffineTransform xform, ImageObserver obs)`
db