{"id": "drag_stop_0",
"position": [-0.42, 1.03]},
{"id": "drag_stop_1",
- "position": [-4.19, 4.66]}]}}
+ "position": [-4.19, 4.66]}]},
+ "start_items": [
+ {"class": "Basketball",
+ "count": 1}]}
"position": [0.42, -2.18]},
{"id": "drag_stop_2",
"position": [0.35, -1.06]}
- ]}}
+ ]},
+ "start_items": [
+ {"class": "Box",
+ "count": 3}]
+}
{"id": "drag_stop_3",
"position": [-1.05, 0.4]}
]
- }}
+ },
+ "start_items": [
+ {"class": "Domino",
+ "count": 2}]}
"position": [3.21, 0.33]},
{"id": "drag_stop_2",
"position": [2.16, 1.87]}
- ]}}
+ ]},
+ "start_items": [
+ {"class": "Box",
+ "count": 2,
+ "mass": 5}]}
"position": [-0.28, -0.85]},
{"id": "drag_stop_4",
"position": [-0.42, -0.85]}
- ]}}
+ ]},
+ "start_items": [
+ {"class": "Box",
+ "count": 1,
+ "mass": 5},
+ {"class": "Domino",
+ "count": 1}]}
"position": [-6.77, 4.66]},
{"id": "drag_stop_2",
"position": [-6.77, 4.24]}
- ]}}
+ ]},
+ "start_items": [
+ {"class": "Box",
+ "count": 2,
+ "mass": 3,
+ "friction": 1}]}
"position": [-2.3, 3.75]},
{"id": "drag_stop_2",
"position": [-2.5, 3.66]}
- ]}}
+ ]},
+ "start_items": [
+ {"class": "Box",
+ "count": 1,
+ "mass": 3,
+ "friction": 1}]}
from direct.interval.LerpInterval import LerpFunctionInterval
from pmachines.items.background import Background
from pmachines.gui.sidepanel import SidePanel
+from pmachines.items.box import Box
+from pmachines.items.basketball import Basketball
+from pmachines.items.domino import Domino
from ya2.utils.cursor import MouseCursor
from ya2.p3d.gfx import P3dGfxMgr
from ya2.p3d.p3d import LibP3d
def _set_items(self):
self.items = []
self._test_items = []
+ if not self.__class__.json:
+ with open(self.__class__.filename) as f:
+ self.__class__.json = loads(f.read())
+ for item in self.__class__.json['start_items']:
+ args = {
+ 'world': self._world,
+ 'plane_node': self._mouse_plane_node,
+ 'cb_inst': self.cb_inst,
+ 'curr_bottom': self.current_bottom,
+ 'repos': self.repos,
+ 'count': item['count']}
+ if 'mass' in item:
+ args['mass'] = item['mass']
+ if 'friction' in item:
+ args['friction'] = item['friction']
+ self.items += [self.__code2class(item['class'])(**args)]
+
+ def __code2class(self, code):
+ return {
+ 'Box': Box,
+ 'Basketball': Basketball,
+ 'Domino': Domino
+ }[code]
def screenshot(self, task=None):
tex = Texture('screenshot')
from pmachines.scene import Scene
from pmachines.items.shelf import Shelf
from pmachines.items.domino import Domino, DownStrategy
-from pmachines.items.basketball import Basketball
class SceneBasketBall(Scene):
return _('Basket ball')
def _set_items(self):
+ super()._set_items()
#self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
#self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
- self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
+ #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, .21))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(1.67, 0, .21))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, -1.45))]
return _('Box')
def _set_items(self):
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
+ super()._set_items()
+ # self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
#self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(.46, 0, -3.95))]
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))]
return _('Domino')
def _set_items(self):
+ super()._set_items()
#self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
#self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-1.2, 0, -.6))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(1.2, 0, -.6))]
- self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=2)]
+ #self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=2)]
self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-1.14, 0, -.04))]
self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 60))
self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-.49, 0, -.04))]
from pmachines.scene import Scene
-from pmachines.items.box import Box
from pmachines.items.shelf import Shelf
from pmachines.items.domino import Domino, UpStrategy, DownStrategy
return _('Domino and box')
def _set_items(self):
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
+ super()._set_items()
+ #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
#self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, .21))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(1.67, 0, .21))]
from pmachines.scene import Scene
-from pmachines.items.box import Box
from pmachines.items.shelf import Shelf
from pmachines.items.domino import Domino, DownStrategy
from pmachines.items.basketball import Basketball
return _('Domino, box and basket ball')
def _set_items(self):
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1, mass=5)]
- self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
+ super()._set_items()
+ #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1, mass=5)]
+ #self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=1)]
self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-.3, 1, 2.5))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, -1.45))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(1.67, 0, -1.45))]
return _('Teeter tooter, domino, box and basket ball')
def _set_items(self):
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=2, friction=1)]
+ super()._set_items()
+ #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=2, friction=1)]
self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(.98, 1, 1.02))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-6.24, 0, -1.45))]
self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-6.24, 0, -1.20))]
return _('Teeter tooter')
def _set_items(self):
- self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=1, friction=1)]
+ super()._set_items()
+ #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=3, count=1, friction=1)]
#self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=5, count=2)]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-2.76, 0, -1.45))]
self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-.56, 0, -1.45))]