Results 1 to 3 of 3
  1. #1
    Witik is offline Member
    Join Date
    Sep 2010
    Posts
    5
    Rep Power
    0

    Default Help Getting Image Coordinates

    Ok, attempt 2 here..

    I need to get the coordinates to draw an image from a string to draw a map with tiles.

    the string
    Java Code:
    private int[][] data = new int[WIDTH][HEIGHT];
    Width and height are both 16
    and the input is like
    Java Code:
    		data[8][2] = BLOCKED;
    currently I'm using
    Java Code:
            	public int getTile(int x, int y) {
    		return data[x][y];
    	}
    and then
    Java Code:
                                    g.drawImage(Tile, getTile(x, y),x*16,y*16, null);
    but that returns an error.
    (the *16 is because the squares are 16*16)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Witik View Post
    Ok, attempt 2 here..

    I need to get the coordinates to draw an image from a string to draw a map with tiles.

    the string
    Java Code:
    private int[][] data = new int[WIDTH][HEIGHT];
    Width and height are both 16
    and the input is like
    Java Code:
    		data[8][2] = BLOCKED;
    currently I'm using
    Java Code:
            	public int getTile(int x, int y) {
    		return data[x][y];
    	}
    and then
    Java Code:
                                    g.drawImage(Tile, getTile(x, y),x*16,y*16, null);
    but that returns an error.
    (the *16 is because the squares are 16*16)
    A few questions for you: what is "an error"? Didn't the jvm or compiler say anything more specific? What is the type of a Tile? That last parameter can't be null; it needs an ImageObserver. You can use the component for an ImageObserver ...

    kind regards,

    Jos

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Witik, please don't start a second thread without responding to the first one. This unnecessarily fragments your discussion. For this reason, I'm going to lock one, please tell me which.

Similar Threads

  1. Coordinates
    By Witik in forum New To Java
    Replies: 3
    Last Post: 09-06-2010, 07:05 AM
  2. Help with printing out new coordinates
    By tyke in forum New To Java
    Replies: 1
    Last Post: 05-10-2010, 06:34 AM
  3. Help with plotting x-y coordinates
    By Fidelcashflow in forum New To Java
    Replies: 3
    Last Post: 12-02-2009, 11:17 AM
  4. Getting mouse coordinates
    By nishant.4545 in forum Advanced Java
    Replies: 3
    Last Post: 07-20-2009, 11:28 PM
  5. button coordinates
    By jacline in forum AWT / Swing
    Replies: 2
    Last Post: 04-05-2009, 10:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •