kivent
kivent copied to clipboard
[Feature] Add 'get_tile_at' function to maps module
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
Would this tie in to translating touch position as well? Just curious! Thanks.
@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 isometric map
@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 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?