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 tilemap new weird behaviors #6957

Merged
merged 12 commits into from
Sep 17, 2024
Merged

Fix tilemap new weird behaviors #6957

merged 12 commits into from
Sep 17, 2024

Conversation

AlexandreSi
Copy link
Collaborator

@AlexandreSi AlexandreSi commented Sep 16, 2024

  • Improve performance display when painting using a PIXI.TilingSprite
  • Fix painting when tilemap is rotated
  • Allow atlas size to be something else than a tile size multiple and ignore last column and row
  • Display error message only when the the tile size is greater than the atlas image
  • Do not crash preview if tilemap badly configured
  • Add object name in actions and conditions

Comment on lines 370 to 375
const allXCoordinates = spritesCoordinatesInTileMapGrid.map(({ x }) => x);
const allYCoordinates = spritesCoordinatesInTileMapGrid.map(({ y }) => y);
const minX = Math.min(...allXCoordinates);
const maxX = Math.max(...allXCoordinates);
const minY = Math.min(...allYCoordinates);
const maxY = Math.max(...allYCoordinates);
Copy link
Owner

Choose a reason for hiding this comment

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

While it looks elegant, probably a better idea to just do a for loop on spritesCoordinatesInTileMapGrid and a if (x < minX) minX = x;, because otherwise you're allocating 2 arrays of easily 500-200 elements at each render (not bad, but ok) and calling Math.min/max with 500-2000 parameters - JS engines are certainly not happy with this.

A good old for loop while be easily optimized by JS engines and even CPUs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah good idea, it was a bit brainless 😅

@@ -940,7 +955,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
'RemoveTileAtGridCoordinates',
_('Remove tile (on the grid)'),
_('Remove the tile at the grid coordinates.'),
_('Remove tile at grid coordinates _PARAM1_ ; _PARAM2_'),
_('Remove tile at grid coordinates _PARAM1_ ; _PARAM2_ of _PARAM0_'),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
_('Remove tile at grid coordinates _PARAM1_ ; _PARAM2_ of _PARAM0_'),
_('Remove tile of _PARAM0_ at grid coordinates _PARAM1_;_PARAM2_'),

@@ -922,7 +937,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
_('Flip tile horizontally (on the grid)'),
_('Flip tile horizontally at grid coordinates.'),
_(
'Flip tile horizontally at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
'Flip tile horizontally at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_ of _PARAM0_'
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
'Flip tile horizontally at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_ of _PARAM0_'
'Flip tile horizontally at grid coordinates _PARAM1_;_PARAM2_ of _PARAM0_: _PARAM3_'

@@ -903,7 +918,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
_('Flip tile vertically (on the grid)'),
_('Flip tile vertically at grid coordinates.'),
_(
'Flip tile vertically at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
'Flip tile vertically at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_ of _PARAM0_'
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
'Flip tile vertically at grid coordinates _PARAM1_ ; _PARAM2_: _PARAM3_ of _PARAM0_'
'Flip tile vertically at grid coordinates _PARAM1_;_PARAM2_ of _PARAM0_: _PARAM3_'

Copy link
Collaborator

@D8H D8H Sep 16, 2024

Choose a reason for hiding this comment

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

I prefer spaces around the semicolon. Otherwise, expressions are hard to read:
image
compared to:
image

@@ -832,7 +847,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
_('Flip tile vertically (at position)'),
_('Flip tile vertically at scene coordinates.'),
_(
'Flip tile vertically at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_'
'Flip tile vertically at scene coordinates _PARAM1_ ; _PARAM2_: _PARAM3_ of _PARAM0_'
Copy link
Owner

Choose a reason for hiding this comment

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

Everywhere: don't put "of " after a boolean but after the scene coordinates.

For coordinates, use X;Y, not X ; Y

@@ -815,7 +830,7 @@ const defineSimpleTileMap = function (extension, _, gd) {
'TileIdAtPosition',
_('Tile (at position)'),
_('the id of the tile at the scene coordinates'),
_('the tile id at scene coordinates _PARAM3_ ; _PARAM4_'),
_('the tile id at scene coordinates _PARAM3_ ; _PARAM4_ of _PARAM0_'),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
_('the tile id at scene coordinates _PARAM3_ ; _PARAM4_ of _PARAM0_'),
_('the tile id of _PARAM0_ at scene coordinates _PARAM3_ ; _PARAM4_'),

Copy link
Owner

@4ian 4ian left a comment

Choose a reason for hiding this comment

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

lgtm once sentences are updated

@AlexandreSi AlexandreSi merged commit e7dac1b into master Sep 17, 2024
6 checks passed
@AlexandreSi AlexandreSi deleted the fix-tilemap-again branch September 17, 2024 09:18
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.

3 participants