kivent icon indicating copy to clipboard operation
kivent copied to clipboard

[Feature] Add 'get_tile_at' function to maps module

Open udiboy1209 opened this issue 7 years ago • 4 comments

The function should take pixel location and return the grid position of tile under that location.

For eg. you have an orthogonal map of 10x10 tiles of size 64x64 px. If we want to find the tile at location (120, 600) the function should return (1,9) (0-indexed position on the grid).

The function should work for all types of maps: orthogonal, isometric, staggered, etc.

@spinningD20 @saqib1707

udiboy1209 avatar Jan 19 '17 20:01 udiboy1209

Would this tie in to translating touch position as well? Just curious! Thanks.

spinningD20 avatar Jan 19 '17 23:01 spinningD20

@udiboy1209 About the staggered tile map implementation -- are they done for normal staggered tile map or for the staggered isometric tile map ?.Since I was taking into consideration the normal staggered but the calculations corresponds to staggered isometric. I am attaching example pics of both kind. Staggered tile map staggered

Staggered isometric map staggered_isometric

saqib1707 avatar Jan 23 '17 15:01 saqib1707

@saqib1707 they only consider staggered isometric for now, as mentioned in the doc. You can keep your calculations under that assumption. The orthogonal tiles staggered arrangement would require one extra parameter, I think which isn't added yet.

udiboy1209 avatar Jan 23 '17 15:01 udiboy1209

@udiboy1209 In the process of adding this feature, I took the indexing of tiles from the bottom and y (y co-ordinate of pixel) from the top edge as mentioned here. But just now I realized that for hexagonal and isometric maps , indexing is from the top-left and pixel_y (y co-ordinate of pixel) is calculated from the bottom edge. Since HexagonalTileMap is inheriting the StaggeredTileMap class, shouldn't the y(pixel value) be taken from the top edge for all kinds of maps?

saqib1707 avatar Jan 28 '17 13:01 saqib1707