ya2 · news · projects · code · about

dds and bam
[pmachines.git] / pmachines / items / box.py
CommitLineData
06af3aa9 1from panda3d.bullet import BulletBoxShape, BulletRigidBodyNode, BulletGhostNode
d5932612 2from pmachines.items.item import Item
1be87278 3
852fb5ae 4
d5932612 5class Box(Item):
32aa4dae 6
80d579b1 7 def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5, friction=.8, model_scale=1):
420ce99a 8 super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/models/bam/box/box.bam', mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction, model_scale=model_scale)
32aa4dae 9
80d579b1 10 def _set_shape(self, apply_scale=True):
ea38777c 11 self.node.add_shape(BulletBoxShape((.5, .5, .5)))
9fc7f6fb
FC
12
13
0e86689f 14class HitStrategy:
9fc7f6fb 15
0e86689f 16 def __init__(self, hit_by, node, world):
9fc7f6fb 17 self._hit_by = hit_by
0e86689f
FC
18 self._node = node
19 self._world = world
9fc7f6fb 20
0a0994e4 21 def win_condition(self):
0e86689f
FC
22 for contact in self._world.contact_test(self._node).get_contacts():
23 other = contact.get_node1() if contact.get_node0() == self._node else contact.get_node0()
9fc7f6fb
FC
24 if other == self._hit_by.node:
25 return True