1. Member
Join Date
May 2012
Posts
6
Rep Power
0

## 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. Member
Join Date
May 2012
Posts
6
Rep Power
0

## Re: Tile Map

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

3. ## Re: Tile Map

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.

4. Member
Join Date
May 2012
Posts
6
Rep Power
0

## Re: Tile Map

Could you give an example? :)

5. ## Re: Tile Map

db

#### Posting Permissions

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