Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the chunk's x and y in hexagonal (staggered) orientation #265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maw3193
Copy link

@maw3193 maw3193 commented Mar 17, 2022

Attached is a zip of a love2d project which should show the problem and how I found a way to fix it in STI.

I've tried using an infinite map using a hexagonal tileset, and ended up with some tiles with negative x,y coordinates.
Using STI unmodified, this mysteriously caused the tiles with negative coordinates (which get put in a chunk with a negative x offset) to end up being drawn very far to the +x instead.

Looking at the code, this seemed to be because when using a staggered orientation, the chunk's x and y values aren't used.
This pull request makes it use those offsets in every orientation.

I'm not sure if this is the correct solution overall, just that it looks sensible and fixes the issue I found.

tileExample.zip

In the attached example, with my patch to STI, hexagonal tiles get drawn to the left of the screen (and you can scroll with the cursor keys and zoom with "=" and "-"). If you revert the latest commit in the Simple-Tiled-Implementation subdirectory, it'll draw those same tiles off to the right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant