Commit | Line | Data |
---|---|---|
e1438449 | 1 | from panda3d.bullet import BulletBoxShape, BulletRigidBodyNode, BulletGhostNode |
b35b1f62 | 2 | from logics.items.item import Item, StillStrategy |
e1438449 FC |
3 | |
4 | ||
5 | class Domino(Item): | |
6 | ||
32cd89ca | 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): |
420ce99a | 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) |
e1438449 | 9 | |
80d579b1 | 10 | def _set_shape(self, apply_scale=True): |
ea38777c | 11 | self.node.add_shape(BulletBoxShape((.1, .25, .5))) |
b41381b2 FC |
12 | |
13 | ||
0e86689f | 14 | class UpStrategy(StillStrategy): |
b41381b2 | 15 | |
0e86689f FC |
16 | def __init__(self, np, tgt_degrees): |
17 | super().__init__(np) | |
b41381b2 | 18 | self._tgt_degrees = tgt_degrees |
0e86689f | 19 | self._np = np |
b41381b2 | 20 | |
0a0994e4 FC |
21 | def win_condition(self): |
22 | return super().win_condition() and abs(self._np.get_r()) <= self._tgt_degrees | |
0e86689f FC |
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 | ||
0a0994e4 | 32 | def win_condition(self): |
32cd89ca | 33 | return self._np.get_z() < -6 or super().win_condition() and abs(self._np.get_r()) >= self._tgt_degrees |