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

fix!: Update IsometricTileMapComponent to have better defined position and size #3142

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

luanpotter
Copy link
Member

@luanpotter luanpotter commented Apr 28, 2024

Description

Update IsometricTileMapComponent to have better defined position and size.

Before, the isometric component "zero" would be the center of the 0,0 block.
However, that does not play nicely with our component system if you want to know the size (i.e. bounding box) of a component.

This changes so that the 0,0 of the component is the 0,0 of the AABB around the isometric tiles. Then, it also computes the size of the component accordingly.

This also changes the example to allow toggling between half and full size more easily.

In our example, this is what it looks like:

image

The example still shows how to compute the previous origin (the purple dot) if you want to.

With full size blocks:

image

I also updated isomash to check if more complex functionality plays well with the new system:
image

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Migration instructions

This is a minor breaking change as you might need to "reposition" your tile components, essentially remove the "compensation" for its location that you probably did yourself. If you were centering the tile component based on the available methods such as map.getBlockCenterPosition, then just make sure you are adding the map.position to that and it should work as before.

@@ -101,6 +104,11 @@ class IsometricTileMapComponent extends PositionComponent {
}
}

@override
void update(double dt) {
_recomputeSize();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the block matrix is not final, theoretically it could be changed at any time. luckily recomputing the size is quite cheap so I think this should be fine.

@luanpotter luanpotter force-pushed the luan.iso branch 2 times, most recently from dbb7717 to 258fabe Compare April 28, 2024 15:52
@luanpotter luanpotter marked this pull request as ready for review April 28, 2024 16:02
@luanpotter luanpotter requested a review from spydon April 28, 2024 16:02
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Lgtm

@luanpotter luanpotter merged commit 9a7bdc7 into main Apr 29, 2024
8 checks passed
@luanpotter luanpotter deleted the luan.iso branch April 29, 2024 15:24
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.

2 participants