Polygon and Circle masks for FlashPunk (round 2)


(azrafe7) #1

Continuing the discussion from Best way for collision detection for lines?:

Sooo… I’ve worked on and off on this in the last days, building on the work I’ve already done on HaxePunk’s previous implementation. Want to know what the new exposed features are supposed to be exactly?

  • Rotatable polygon mask (w/ pivot point)
  • Circle mask
  • Improved Masklist (now hopefully showing && working correctly with Hitboxes and Polygons)
  • All masks should correctly interact with any other type
  • Added support for Image to create a representation of a Polygon (and thus sync with it)

[code | online demo | offline demo (106.2 KB)]

One notable thing is that now it should be possible to create complex masks without having to resort to Pixelmask (see Mario in the demo, which is a Masklist of Polygon masks with a common pivot).

Although I’ve runned tests with all the edge cases that have come to mind I cannot guarantee it’s bug free, so please test it further and report any issues you may find here (or file an issue on the github repo… or better yet a Pull Request?! :smirk:).

Feel free to drop a line if you have trouble using it or have any question .

PS: Haven’t made a PR to the main repo yet 'cause I’d like to have a round of tests and feedbacks first, but I’d be glad to make one once things are proven to be stable enough.


I wanted pixel perfect collision for scenery but Pixelmask doesn't seem suitable
(Zachary Lewis) #2

Go ahead and submit a pull request. We can use that to discuss issues before merging.


(azrafe7) #3

They’re quite a bunch of commits, hehe… :smirk:

…Submitted! https://github.com/Draknek/FlashPunk/pull/133