class Box(Item):
- def __init__(self, world, plane_node, count, cb_inst, curr_bottom):
- super().__init__(world, plane_node, count, cb_inst, curr_bottom, 'assets/gltf/box/box.gltf')
+ def __init__(self, world, plane_node, count, cb_inst, curr_bottom, repos):
+ super().__init__(world, plane_node, count, cb_inst, curr_bottom, repos, 'assets/gltf/box/box.gltf')
def _set_phys(self):
super()._set_phys()
--- /dev/null
+from panda3d.bullet import BulletBoxShape, BulletRigidBodyNode, BulletGhostNode
+from pmachines.items.item import Item
+
+
+class Domino(Item):
+
+ def __init__(self, world, plane_node, count, cb_inst, curr_bottom, repos):
+ super().__init__(world, plane_node, count, cb_inst, curr_bottom, repos, 'assets/gltf/domino/domino.gltf')
+
+ def _set_phys(self):
+ super()._set_phys()
+ self._shape = BulletBoxShape((.1, .25, .5))
class Item:
- def __init__(self, world, plane_node, count, cb_inst, curr_bottom, model_path):
+ def __init__(self, world, plane_node, count, cb_inst, curr_bottom, scene_repos, model_path):
self._world = world
self._plane_node = plane_node
self._count = count
self._first_command = True
self.repos_done = False
self._curr_bottom = curr_bottom
+ self._scene_repos = scene_repos
self._model_path = model_path
self._commands = []
self._command_idx = -1
self._txt['pos'] = p2d
self.repos_done = True
+ def repos_x(self, x):
+ self._np.set_x(x)
+ bounds = self._np.get_tight_bounds()
+ bounds = bounds[0] - self._np.get_pos(), bounds[1] - self._np.get_pos()
+ pos = self._np.get_pos() + (bounds[1][0], bounds[0][1], bounds[0][2])
+ p2d = P3dGfxMgr.screen_coord(pos)
+ self._txt['pos'] = p2d
+
def get_bottom(self):
bounds = self._np.get_tight_bounds()
bounds = bounds[0] - self._np.get_pos(), bounds[1] - self._np.get_pos()
self._txt.destroy()
self._count -= 1
if self._count:
- item = self.__class__(self._world, self._plane_node, self._count, self._cb_inst) # pylint: disable=no-value-for-parameter
+ item = self.__class__(self._world, self._plane_node, self._count, self._cb_inst, self._curr_bottom, self._scene_repos) # pylint: disable=no-value-for-parameter
self._cb_inst(item)
+ self._scene_repos()
def on_click_r(self, pos):
if self._paused: return
class Shelf(Item):
- def __init__(self, world, plane_node, count, cb_inst, curr_bottom):
- super().__init__(world, plane_node, count, cb_inst, curr_bottom, 'assets/gltf/shelf/shelf.gltf')
+ def __init__(self, world, plane_node, count, cb_inst, curr_bottom, repos):
+ super().__init__(world, plane_node, count, cb_inst, curr_bottom, repos, 'assets/gltf/shelf/shelf.gltf')
def _set_phys(self):
super()._set_phys()
from pmachines.items.background import Background
from pmachines.items.box import Box
from pmachines.items.shelf import Shelf
+from pmachines.items.domino import Domino
from pmachines.sidepanel import SidePanel
from lib.engine.gui.cursor import MouseCursor
from lib.lib.p3d.gfx import P3dGfxMgr
def reset(self):
[itm.destroy() for itm in self.items]
- self.items = [Box(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom)]
- self.items += [Shelf(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom)]
+ self.items = [Box(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
+ self.items += [Shelf(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
+ self.items += [Domino(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
self._commands = []
self._command_idx = 0
[item.on_release() for item in self.items]
self._cursor.set_image('assets/buttons/arrowUpLeft.png')
- def on_aspect_ratio_changed(self):
+ def repos(self):
for item in self.items:
item.repos_done = False
+ self.items = sorted(self.items, key=lambda itm: itm.__class__.__name__)
[item.on_aspect_ratio_changed() for item in self.items]
self._side_panel.update(self.items)
+ max_x = -9
+ for item in self.items:
+ if not item._instantiated:
+ max_x = max(item._np.get_x(), max_x)
+ for item in self.items:
+ if not item._instantiated:
+ item.repos_x(max_x)
+
+ def on_aspect_ratio_changed(self):
+ self.repos()
def on_frame(self, task):
hits = self._get_hits()
* issues
* todo
** implement other items
-*** domino
*** basketball
*** teeter_tooter
** create one level per item, then levels with more items
** version 0.0.yymmdd
** do intro video with moviepy
** android build
-** magnet
+** magnet, road cone, bucket
* waiting
** itch.io's client works with wine: functional tests for windows-itch.io
* maybe/someday