landgreen / n-gon

2-d physics rogue-lite platformer shooter
https://landgreen.github.io/n-gon/
GNU General Public License v3.0
144 stars 208 forks source link

Concave objects not working? #52

Closed Whyisthisnotavalable closed 1 year ago

Whyisthisnotavalable commented 1 year ago

spawn.mapVertex(0, 10000, "0 0 10000 10000 20000 0 15000 -20000 10000 -10000 5000 -20000") This does not work

landgreen commented 1 year ago

2-D physics engines only support convex shapes. So in matter.js you would need to 2+ shapes to make a cave.

Whyisthisnotavalable commented 1 year ago

Then whats decomp in the library folder used for?

landgreen commented 1 year ago

google bard says:

The poly-decomp library module for Matter.js enables concave vertex decomposition support when using Bodies.fromVertices. The poly-decomp library decomposes 2D polygons into convex pieces in JavaScript. You can install the poly-decomp library and use Common. You can also try drawing a polygon using the poly-decomp.js Github repo. There's also an online poly-decomp playground where you can view and fork poly-decomp examples.

landgreen commented 1 year ago

so it looks like it's used to turn concave into convex. But you can also just do it manually, which is what I do. I'm not sure how to get the auto decomp to work so let me know if you figure it out.

Whyisthisnotavalable commented 1 year ago

The hitbox works, it's just that it acts as if decomp was not there.

Whyisthisnotavalable commented 1 year ago

What I mean is, the decomp did work, you just didn't render things correctly.