karai17 / Simple-Tiled-Implementation

Tiled library for LÖVE
Other
840 stars 121 forks source link

Box2d Plugin - Added static bodies support. #239

Closed 133794m3r closed 4 years ago

133794m3r commented 4 years ago

Since box2d support is in here. For things like the ground/walls there should be support for static bodies. This patch does just that. One line change really.

karai17 commented 4 years ago

Should the code path for static data also be creating a new body that is flagged as dynamic, or should that be flagged as something else?

https://love2d.org/wiki/BodyType

133794m3r commented 4 years ago

In box2d I believe bodies can only be kinematic, dynamic, or static. That's why I made it and elseif. For all 3 types I don't believe they can be both for the object.

So in reality,it should also do another elseif for kinematic.

If you're doing a platformer, I can't see anything requiring multiple simulations on the same body. It does need kinematic for springs and similar bouncy things in a platformer where you have something that causes the player object(or other objects) to bounce upon hitting it.

But I'd say that each object only needs a single body type, and the related data properties about like what it's friction, bounciness(restitution I believe it's called), or any other property can be combined with it but some of them will be of no use, as a static body doesn't bounce.

karai17 commented 4 years ago

Right, but what I am saying is that in your PR, both static and dynamic userdata objects are being turned into dynamic bodies. Was that intentional, or is the new line of code supposed to be static?

133794m3r commented 4 years ago

Woops, I forgot to change the property after copy-pasting that line of code. it isn't supposed to be like that. I literally just copy-pasted it so that it followed the same style. Sorry I didn't catch on before. I'll modify the code to work properly on that branch.

133794m3r commented 4 years ago

I'm dumb and instead of having 3 commits to do what should've been a single one it's now in #240 it's 2 commits b/c I forgot to include comments about the new body types but I think the thing is fixed now.