class Basketball(Item):
- def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.92):
- super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/basketball/basketball.gltf', .4, mass=mass, pos=pos, r=r, count=count, restitution=restitution)
+ def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.92, friction=.6):
+ super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/basketball/basketball.gltf', .4, mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction)
def _set_shape(self):
self.node.add_shape(BulletSphereShape(1))
class Box(Item):
- def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5):
- super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/box/box.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution)
+ 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):
+ super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/box/box.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction)
def _set_shape(self):
self.node.add_shape(BulletBoxShape((.5, .5, .5)))
class Domino(Item):
- def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5):
- super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/domino/domino.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution)
+ 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):
+ super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/domino/domino.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction)
def _set_shape(self):
self.node.add_shape(BulletBoxShape((.1, .25, .5)))
self._np = np
def win_condition(self):
- return self._np.get_z() < -10 or super().win_condition() and abs(self._np.get_r()) >= self._tgt_degrees
+ return self._np.get_z() < -6 or super().win_condition() and abs(self._np.get_r()) >= self._tgt_degrees
def win_condition(self):
self._positions += [self._np.get_pos()]
self._rotations += [self._np.get_hpr()]
- if len(self._positions) > 10:
+ if len(self._positions) > 30:
self._positions.pop(0)
- if len(self._rotations) > 10:
+ if len(self._rotations) > 30:
self._rotations.pop(0)
- if len(self._positions) < 8:
+ if len(self._positions) < 28:
return
avg_x = sum(pos.x for pos in self._positions) / len(self._positions)
avg_y = sum(pos.y for pos in self._positions) / len(self._positions)
class Item:
- def __init__(self, world, plane_node, cb_inst, curr_bottom, scene_repos, model_path, model_scale=1, exp_num_contacts=1, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5):
+ def __init__(self, world, plane_node, cb_inst, curr_bottom, scene_repos, model_path, model_scale=1, exp_num_contacts=1, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5, friction=.5):
self._world = world
self._plane_node = plane_node
self._count = count
self._commands = []
self._command_idx = -1
self._restitution = restitution
+ self._friction = friction
self._positions = []
self._rotations = []
if count:
self.node.set_mass(self._mass)
self._world.attach_rigid_body(self.node)
self.node.set_restitution(self._restitution)
+ self.node.set_friction(self._friction)
def on_click_l(self, pos):
if self._paused: return
self._txt.set_alpha_scale(1)
def fail_condition(self):
- if self._np.get_z() < -10:
+ if self._np.get_z() < -6:
return True
self._positions += [self._np.get_pos()]
self._rotations += [self._np.get_hpr()]
- if len(self._positions) > 10:
+ if len(self._positions) > 30:
self._positions.pop(0)
- if len(self._rotations) > 10:
+ if len(self._rotations) > 30:
self._rotations.pop(0)
- if len(self._positions) < 8:
+ if len(self._positions) < 28:
return
avg_x = sum(pos.x for pos in self._positions) / len(self._positions)
avg_y = sum(pos.y for pos in self._positions) / len(self._positions)
class Shelf(Item):
- def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5):
- super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/shelf/shelf.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution)
+ 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):
+ super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/shelf/shelf.gltf', mass=mass, pos=pos, r=r, count=count, restitution=restitution, friction=friction)
def _set_shape(self):
self.node.add_shape(BulletBoxShape((1, .5, .05)))
class TeeterTooter(Item):
- def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5):
- super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/teeter_tooter/teeter_tooter.gltf', exp_num_contacts=2, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=restitution)
+ def __init__(self, world, plane_node, cb_inst, curr_bottom, repos, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=.5, friction=.5):
+ super().__init__(world, plane_node, cb_inst, curr_bottom, repos, 'assets/gltf/teeter_tooter/teeter_tooter.gltf', exp_num_contacts=2, mass=1, pos=(0, 0, 0), r=0, count=0, restitution=restitution, friction=friction)
def _set_shape(self):
self.node.add_shape(
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(4.43, 0, -3.95))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-1.29, 0, .26), r=28.45)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(2.15, 0, -1.49), r=28.45)]
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-1.55, 0, 1.23))]
+ self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-1.55, 0, 1.23), friction=.4)]
self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(4.38, 0, -3.35))]
self.items[-1].set_strategy(HitStrategy(self.items[-2], self.items[-1].node, self.items[-1]._world))
#self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=2)]
* issues
* todo
-** fix level names
-** add friction (level domino + box + basket ball)
** level teetertooter
** level domino + box + basketball + teetertooter
+** buttons of the scenes with played indications
+*** each scene has a last-modification
+*** when you win save the id + last-modification
+*** put a check if id is saved and last-modifications are equal
** intro animation (from target item to start position)
** optimize images creation (python setup.py images)
** use dds files in place of png/jpg