# Tile Map

• 05-19-2012, 03:51 PM
Lundager
Tile Map
I am wondering how do I measure the screen, so I can match an array lets say I have this multidimensional array:

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?
• 05-19-2012, 04:07 PM
Fubarable
Re: Tile Map
The Toolkit class has a getScreenSize() method that you can possibly use.
• 05-19-2012, 06:25 PM
Lundager
Re: Tile Map
Aren't there some mathematical way? Like HEIGHT / Something * WIDTH / Something?? Or what?
• 05-19-2012, 06:29 PM
Fubarable
Re: Tile Map
Quote:

Originally Posted by Lundager
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.
• 05-19-2012, 06:37 PM
Lundager
Re: Tile Map
Could you give an example? :)
• 05-19-2012, 08:09 PM
DarrylBurke
Re: Tile Map