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

Hexagonal get tile corners #6826

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ukamp
Copy link

@ukamp ukamp commented May 25, 2024

This PR

  • Fixes a bug

Describe the changes below:

  • Declaration of tempVec was missing
  • Added rotation for staggerAxis = x

ukamp added 2 commits May 25, 2024 17:25
- Declaration of tempVec was missing
- Added rotation for staggerAxis = x
changed this.HexagonalTileToWorldXY (left over from labs.phaser.io test) to HexagonalTileToWorldXY

corners.push(new Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle))));
corners.push(new Phaser.Math.Vector2(center.x + (hexWidth * Math.cos(angle)), center.y + (hexHeight * Math.sin(angle))));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't do this. Require the Vector2 and use it as per the original code. You cannot guarantee Phaser will exist in the global scope.

Copy link
Author

Choose a reason for hiding this comment

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

Good Point

var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer);

var corners = [];

// Hard-coded orientation values for Pointy-Top Hexagons only
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove a useful comment?

Copy link
Author

Choose a reason for hiding this comment

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

The comment is contradictory, the value is not only used for Pointy-Top Hexagons, but an aid to calculating the long diagonals. Better comment: We assume a pointy-top orientation.

@@ -35,13 +35,13 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer)
}

// Sets the center of the tile into tempVec
var tempVec = new Phaser.Math.Vector2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be a Vector2 and required.

@photonstorm
Copy link
Collaborator

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Added missing declaration for tempVec in /src/tilemaps/components/HexagonalGetTileCorners.js
  • Introduced rotation adjustment for staggerAxis = 'x' in hexagonal tile corner calculations

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

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