mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
ccb4d84d8b
commit
d36ad2081b
@ -156,5 +156,15 @@ void PyWorld::_register(VM* vm, PyObject* mod, PyObject* type){
|
|||||||
self._debug_draw.draw_like = args[1];
|
self._debug_draw.draw_like = args[1];
|
||||||
return vm->None;
|
return vm->None;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
// joints
|
||||||
|
vm->bind(type, "create_weld_joint(self, a, b)", [](VM* vm, ArgsView args){
|
||||||
|
PyWorld& self = _CAST(PyWorld&, args[0]);
|
||||||
|
PyBody& bodyA = CAST(PyBody&, args[1]);
|
||||||
|
PyBody& bodyB = CAST(PyBody&, args[2]);
|
||||||
|
b2WeldJointDef def;
|
||||||
|
def.Initialize(bodyA.body, bodyB.body, bodyA.body->GetWorldCenter());
|
||||||
|
b2Joint* p = self.world.CreateJoint(&def);
|
||||||
|
return VAR(p); // void_p
|
||||||
|
});
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
@ -88,6 +88,9 @@ class World:
|
|||||||
def set_debug_draw(self, draw: _DrawLike):
|
def set_debug_draw(self, draw: _DrawLike):
|
||||||
"""set the debug draw object."""
|
"""set the debug draw object."""
|
||||||
|
|
||||||
|
def create_weld_joint(self, body_a: 'Body', body_b: 'Body'):
|
||||||
|
"""create a weld joint between two bodies."""
|
||||||
|
|
||||||
class Body:
|
class Body:
|
||||||
type: int # 0-static, 1-kinematic, 2-dynamic, by default 2
|
type: int # 0-static, 1-kinematic, 2-dynamic, by default 2
|
||||||
gravity_scale: float
|
gravity_scale: float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user