korlibs / korlibs/korge-tiled

improvement for tilemaps: pixelToTileCoords()

Open
#8 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Currently we have no method to transform the screen coordinates from e.g a mouse click to get the tile coordinates to get the tile properties from the tilemap.

ok for normal orthogonal tilemaps it is easy but for staggered isometric tilemaps it is a bit more complicated.

tiled has a cpp implementation for all 4 tilemap types:
https://github.com/mapeditor/tiled/blob/master/src/libtiled/hexagonalrenderer.cpp
https://github.com/mapeditor/tiled/blob/master/src/libtiled/orthogonalrenderer.cpp
https://github.com/mapeditor/tiled/blob/master/src/libtiled/isometricrenderer.cpp
https://github.com/mapeditor/tiled/blob/master/src/libtiled/staggeredrenderer.cpp

maybe it would be good too to get the "real" clicked tile coordinates when someone click on a tile in a layered staggered tile with a collider.

For example the red dots are the clicks and now it would be great to have a method to get the "green highlighted" tiles with coordinates and layer.

![example](https://user-images.githubusercontent.com/407540/167219071-e9f25975-42cd-40aa-9543-50dfc035e447.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the four Tiled renderer references in the issue: hexagonalrenderer.cpp, orthogonalrenderer.cpp, isometricrenderer.cpp, and staggeredrenderer.cpp. Compare their coordinate transformations with the tilemap entry points in this repository. Done should include pixelToTileCoords() behavior for the four tilemap types and identify the clicked tile coordinates and layer for layered staggered maps with colliders.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
computer-graphics, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.