ya2 · news · projects · code · about

fix: building of screenshots
[pmachines.git] / pmachines / items / domino.py
1 from panda3d.bullet import BulletBoxShape, BulletRigidBodyNode, BulletGhostNode
2 from pmachines.items.item import Item, StillStrategy
3
4
5 class Domino(Item):
6
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=.6):
8 super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/models/bam/domino/domino.bam', mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction)
9
10 def _set_shape(self, apply_scale=True):
11 self.node.add_shape(BulletBoxShape((.1, .25, .5)))
12
13
14 class UpStrategy(StillStrategy):
15
16 def __init__(self, np, tgt_degrees):
17 super().__init__(np)
18 self._tgt_degrees = tgt_degrees
19 self._np = np
20
21 def win_condition(self):
22 return super().win_condition() and abs(self._np.get_r()) <= self._tgt_degrees
23
24
25 class DownStrategy(StillStrategy):
26
27 def __init__(self, np, tgt_degrees):
28 super().__init__(np)
29 self._tgt_degrees = tgt_degrees
30 self._np = np
31
32 def win_condition(self):
33 return self._np.get_z() < -6 or super().win_condition() and abs(self._np.get_r()) >= self._tgt_degrees