# GMS 2Find Tile Layer's Width and Height

#### 2d_warrior

##### Member
Is there any way to find the width, and height of a tile layer. Width meaning the x of the first tile in the left direction to the x of the last tile + the tile's width in the right direction. Height meaning the y of the first tile in the up direction to the y of the last tile + the tile's height in the down direction. Finding how many tiles are in each direction in the tile layer would also help me get the result. I'm assuming I don't already know how wide or high the given tile layer is. I'm talking about an in game tile layer (an arrangement of tiles), not the tile set resources, if that was ambiguous.

Edit:
So I tried tilemap_get_width(i), but this just gives me how many could fit in the room horizontally, not the amount of tiles from the first horizontally placed to the last horizontally placed. It count's the empties before and after.

Last edited:

#### Slyddar

##### Member
The tile layer dimensions will always fill the room, as best as it can. To get how far the tile layer is populated for the width and height, I would imagine you would have to calculate that yourself, using a loop and some tilemap_get_at_pixel testing. You could start at the extremity of the room and test every tile row/column counting down.

Last edited:

#### 2d_warrior

##### Member
The tile layer dimensions will always fill the room, as best as it. To get how far the tile layer is populated for the width and height, I would imagine you would have to calculate that yourself, using a loop and some tilemap_get_at_pixel testing. You could start at the extremity of the room and test every tile row/column counting down.
Would have thought getting the dimensions of a tilemap would have been built in. The loop method sounds expensive, but I guess I'll give it a try. Not sure why we have tilemap_get_width(i) if not for that. Dividing room height by tile cell size is easier to do yourself than this is going to be.