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

Tilemap DiagonalPolicy #1659

Merged
merged 8 commits into from
Nov 16, 2015
Merged

Tilemap DiagonalPolicy #1659

merged 8 commits into from
Nov 16, 2015

Conversation

larsiusprime
Copy link
Member

I was debugging some pathfinding issues and noticed that FlxTilemap seems to always assume that diagonal movement is possible when it's calculating the distances during the A* / Dijkstra's algorithm step.

There was a parameter to modify this, but only to specify whether the diagonal was "wide" or not, ie, whether it would take an additional point to take the diagonal, or whether it was the same as an orthogonal step. There was no way I could see to disallow diagonals entirely.

So, this change swaps out the WideDiagonal:Bool for DiagonalPolicy:FlxTilemapDiagonalPolicy, which is an abstract enum.

Why an abstract enum and not a regular enum? Because the previous behavior is to set a default value of Wide Diagonals, and you can't assign an enum as a default parameter because it's technically not a constant and the compiler complains.

FlxTilemapDiagonalPolicy has three values -- NONE, NORMAL, and WIDE.

WIDE has the same behavior as previously setting the WideDiagonal value to true, and NORMAL has the same behavior as previously setting the WideDiagonal value to false.

NONE will make the calculator skip the up && right, down && left, etc, steps, and only consider orthogonal movement.

@larsiusprime
Copy link
Member Author

@MSGhero wisely points out that using Abstract Null<Bool> as the underlying type avoids a breaking change.

Gama11 added a commit that referenced this pull request Nov 16, 2015
@Gama11 Gama11 merged commit 7f2fb0d into HaxeFlixel:dev Nov 16, 2015
@larsiusprime larsiusprime deleted the tilemap_diagonal branch December 10, 2015 14:17
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