-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Hexagonal get tile corners #6826
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
| var center = HexagonalTileToWorldXY(tileX, tileY, tempVec, camera, layer); | ||
|
|
||
| var corners = []; | ||
|
|
||
| // Hard-coded orientation values for Pointy-Top Hexagons only | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove a useful comment?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| var b0 = 0.5773502691896257; // Math.sqrt(3) / 3 | ||
|
|
||
| var rotation = 0; | ||
| var hexWidth; | ||
| var hexHeight; | ||
|
|
||
|
|
@@ -54,13 +54,15 @@ var HexagonalGetTileCorners = function (tileX, tileY, camera, layer) | |
| { | ||
| hexWidth = tileWidth / 2; | ||
| hexHeight = b0 * tileHeight; | ||
| rotation = 30 * Math.PI /180; | ||
| } | ||
|
|
||
| for (var i = 0; i < 6; i++) | ||
| { | ||
| var angle = 2 * Math.PI * (0.5 - i) / 6; | ||
| angle += rotation; | ||
|
|
||
| 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)))); | ||
|
||
| } | ||
|
|
||
| return corners; | ||
|
|
||
There was a problem hiding this comment.
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.