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

FlxPathfinder - Overhaul to pathfinding #2480

Merged
merged 37 commits into from
May 9, 2022

Conversation

Geokureli
Copy link
Member

@Geokureli Geokureli commented Jan 7, 2022

I moved all of the pathfinding logic to a new class, so that it can be extended with different algorithms
Excerpt from FlxPathfinder docs:

Used to find paths in a FlxBaseTilemap. extend this class and override
getNeighbors and getDistance to create you're own! For top-down maps, it may
be wiser to extend FlxDiagonalPathfinder, as it already has a lot of basic helpers.

To use, either call myPathfinder.findPath(myMap, start, end) or
myMap.findPathCustom(myPathfinder, start, end)

I plan to add a platformer pathfinder, too, but that doesn't need to be included here.

No breaking changes, just more ways to execute pathfinding. Im open to ideas for unit tests, I'll try to think of some.

@Geokureli Geokureli changed the title Path policy FlxPathfinder Jan 7, 2022
@Geokureli Geokureli added this to the 5.0.0 milestone Apr 20, 2022
@Geokureli Geokureli mentioned this pull request Apr 20, 2022
10 tasks
@Geokureli Geokureli changed the title FlxPathfinder FlxPathfinder - Overhaul to pathfinding Apr 20, 2022
@Geokureli
Copy link
Member Author

New features:

  • FlxCollision: Added calcRectEntry and calcRectExit (#2480)
  • FlxTilemap: Overhaul to pathfinding (#2480)
    • FlxPathfinder: Allows customizable pathfinding algorithms for tilemap
    • FlxPathSimplifier: Replace findPath simplify args with a new enum
    • Expose previously private fields: tileWidth, tileHeight, scaledTileWidth, scaledTileHeight, scaledWidth, and scaledHeight
    • FlxBaseTilemap: added calcRayEntry and calcRayExit
  • FlxPath: added immovable bool (previously object were always immovable when following paths) (#2480)
  • FlxPathDrawData: added myFlxPath.debugDrawData to allow custom colors and draw properties (#2480)
  • FlxDirectionFlags: added fromBools static helper (#2480)
  • FlxAxes: added x and y getters and NONE value (#2480)

Changes and improvements:

  • FlxTilemap: Renamed ray to rayStep added new ray with no resolution arg (#2480)
  • FlxPath: move to flixel.path.FlxPath (#2480)

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.

1 participant