Results 1 to 6 of 6

Thread: Tile Map

  1. #1
    Lundager is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Post Tile Map

    I am wondering how do I measure the screen, so I can match an array lets say I have this multidimensional array:

    Java Code:
    int map[][] =
         {{0,0,0,0,1,0,0,0,0,0},
         {0,0,0,0,1,0,1,1,1,0},
         {0,1,1,1,1,0,1,0,1,0},
         {0,0,0,0,1,0,1,0,1,0},
         {0,1,1,0,1,0,1,0,1,0},
         {0,0,1,0,1,0,1,0,1,0},
         {0,0,1,0,0,0,1,0,1,0},
         {0,0,1,1,1,1,1,0,1,0},
         {0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0}};
    Where 0 is empty space and 1 is lets say walls
    How do I know how many rows and columns I need to have for a specific screen size?
    Can I convert pixels to tile size/multidimensional array tile size?

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

  3. #3
    Lundager is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Default Re: Tile Map

    Aren't there some mathematical way? Like HEIGHT / Something * WIDTH / Something?? Or what?

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

    Default Re: Tile Map

    Quote Originally Posted by Lundager View Post
    Aren't there some mathematical way? Like HEIGHT / Something * WIDTH / Something?? Or what?
    Yes. You start with the dimensions of the screen, which you can get via the Toolkit class as I mentioned above, and then you use the row and column counts of your 2-D array and use basic algebra to calculate your values.

  5. #5
    Lundager is offline Member
    Join Date
    May 2012
    Posts
    6
    Rep Power
    0

    Default Re: Tile Map

    Could you give an example? :)

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default Re: Tile Map

    Moved from Advanced Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 11
    Last Post: 01-27-2012, 03:50 PM
  2. Help tile TimeScrambler game
    By DrCooksAlot in forum New To Java
    Replies: 8
    Last Post: 01-25-2012, 03:12 PM
  3. Simple Tile Game Question
    By sgthale in forum Java Applets
    Replies: 9
    Last Post: 06-17-2011, 11:20 AM
  4. Concept of Tile map via database
    By GrInd3r in forum New To Java
    Replies: 0
    Last Post: 12-08-2010, 05:18 PM
  5. Replies: 3
    Last Post: 11-06-2010, 12:33 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
  •