ya2 · news · projects · code · about

json: test items
authorFlavio Calva <f.calva@gmail.com>
Thu, 22 Sep 2022 18:25:18 +0000 (19:25 +0100)
committerFlavio Calva <f.calva@gmail.com>
Thu, 22 Sep 2022 18:25:18 +0000 (19:25 +0100)
15 files changed:
assets/scenes/basketball.json
assets/scenes/box.json
assets/scenes/domino.json
assets/scenes/domino_box.json
assets/scenes/domino_box_basketball.json
assets/scenes/teeter_domino_box_basketball.json
assets/scenes/teeter_tooter.json
pmachines/scene.py
pmachines/scenes/scene_basketball.py
pmachines/scenes/scene_box.py
pmachines/scenes/scene_domino.py
pmachines/scenes/scene_domino_box.py
pmachines/scenes/scene_domino_box_basketball.py
pmachines/scenes/scene_teeter_domino_box_basketball.py
pmachines/scenes/scene_teeter_tooter.py

index aca901b1cffacdaad0aadffe5b38e82923d92117..918214ea0039886568f53458357193b31ac930dc 100644 (file)
@@ -1 +1,11 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [55, 50]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [-0.42, 1.03]},
+        {"id": "drag_stop_1",
+         "position": [-4.19, 4.66]}]}}
index aca901b1cffacdaad0aadffe5b38e82923d92117..bb366a2bacc9daa50d93d83e8d1e9f4db440f289 100644 (file)
@@ -1 +1,14 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [65, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [0.42, -3.29]},
+        {"id": "drag_stop_1",
+         "position": [0.42, -2.18]},
+        {"id": "drag_stop_2",
+         "position": [0.35, -1.06]}
+     ]}}
index aca901b1cffacdaad0aadffe5b38e82923d92117..ebd3fd67b34f530fa406f7fe13ceeff5ebd58fae 100644 (file)
@@ -1 +1,19 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [35, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [-1.82, 0.06]},
+        {"id": "drag_stop_1",
+         "position": [0.49, 0.06]},
+        {"id": "drag_stop_2",
+         "position": [-1.54, 0.06]},
+        {"id": "drag_start_1",
+         "position": [-1.54, 0.4]},
+        {"id": "drag_stop_3",
+         "position": [-1.05, 0.4]}
+     ]
+ }}
index aca901b1cffacdaad0aadffe5b38e82923d92117..fd1971eb21c3ec0f7635cf56212cdbf8095afaae 100644 (file)
@@ -1 +1,14 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [65, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [3.21, -0.78]},
+        {"id": "drag_stop_1",
+         "position": [3.21, 0.33]},
+        {"id": "drag_stop_2",
+         "position": [2.16, 1.87]}
+     ]}}
index aca901b1cffacdaad0aadffe5b38e82923d92117..d5e0af3c6a5320644a8ed2b5fac22ccb4e1bff55 100644 (file)
@@ -1 +1,24 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [65, 60]},
+        {"id": "drag_start_1",
+         "position": [30, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [-1.4, -0.78]},
+        {"id": "drag_stop_1",
+         "position": [-1.26, 0.2]},
+        {"id": "drag_stop_2",
+         "position": [-0.28, -0.78]},
+        {"id": "drag_start_2",
+         "position": [-0.28, -0.57]},
+        {"id": "drag_stop_3",
+         "position": [-0.77, -0.57]},
+        {"id": "drag_start_3",
+         "position": [-0.28, -0.85]},
+        {"id": "drag_stop_4",
+         "position": [-0.42, -0.85]}
+     ]}}
index aca901b1cffacdaad0aadffe5b38e82923d92117..c0c9c4b2b14654b9375d3bc759b181133015c942 100644 (file)
@@ -1 +1,16 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [60, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [-7.33, 4.24]},
+        {"id": "drag_stop_1",
+         "position": [-7.12, 4.24]},
+        {"id": "drag_start_1",
+         "position": [-6.77, 4.66]},
+        {"id": "drag_stop_2",
+         "position": [-6.77, 4.24]}
+     ]}}
index aca901b1cffacdaad0aadffe5b38e82923d92117..c2db52026e3d2555e4a3b8faab1d56bb57a39259 100644 (file)
@@ -1 +1,16 @@
-{"version": "220914"}
+{"version": "220914",
+ "test_items": {
+     "pixel_space": [
+        {"id": "drag_start_0",
+         "position": [60, 60]}
+     ],
+     "world_space": [
+        {"id": "drag_stop_0",
+         "position": [-2.65, 1.18]},
+        {"id": "drag_stop_1",
+         "position": [-2.65, 3.27]},
+        {"id": "drag_start_1",
+         "position": [-2.3, 3.75]},
+        {"id": "drag_stop_2",
+         "position": [-2.5, 3.66]}
+     ]}}
index 31660ece45ebdf563fcafc44ecca778d4310a68b..b77cf6f53395dcbab9e5087d20051f08ba665259 100644 (file)
@@ -676,6 +676,15 @@ class Scene(DirectObject):
                 self._pos_mgr.register(itm.name, P3dGfxMgr.pos2d_p2d(itm))
         taskMgr.doMethodLater(.01, frame_after, 'frame after')
 
+    def _define_test_items(self):
+        if not self.__class__.json:
+            with open(self.__class__.filename) as f:
+                self.__class__.json = loads(f.read())
+        for item in self.__class__.json['test_items']['pixel_space']:
+            self._pos_mgr.register(item['id'], tuple(item['position']))
+        for item in self.__class__.json['test_items']['world_space']:
+            self._set_test_item(item['id'], tuple(item['position']))
+
     def _set_test_item(self, name, pos):
         self._test_items += [NodePath(name)]
         self._test_items[-1].set_pos(pos[0], 0, pos[1])
index c3f24938a4f2bf9233810df09a005c8d47a54ccf..e8a76a544c988145c967353601b53ac8fb5e97eb 100644 (file)
@@ -47,10 +47,10 @@ class SceneBasketBall(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (55, 50))
-        self._set_test_item('drag_stop_0', (-.42, 1.03))
-        self._set_test_item('drag_stop_1', (-4.19, 4.66))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (55, 50))
+        self._set_test_item('drag_stop_0', (-.42, 1.03))
+        self._set_test_item('drag_stop_1', (-4.19, 4.66))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index 6997fa22d0373d33f1602f7d2f7f1d643b8d27af..d86be97aa601b2cc0c6d5bd1893c94d6442bed88 100644 (file)
@@ -30,11 +30,11 @@ class SceneBox(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (65, 60))
-        self._set_test_item('drag_stop_0', (.42, -3.29))
-        self._set_test_item('drag_stop_1', (.42, -2.18))
-        self._set_test_item('drag_stop_2', (.35, -1.06))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._set_test_item('drag_stop_0', (.42, -3.29))
+        self._set_test_item('drag_stop_1', (.42, -2.18))
+        self._set_test_item('drag_stop_2', (.35, -1.06))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index 5467afd915a08e0a6cec442109842987959fb457..b5c87ad4d1d5249371ab756e0e433295b55980f3 100644 (file)
@@ -30,13 +30,13 @@ class SceneDomino(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (35, 60))
-        self._set_test_item('drag_stop_0', (-1.82, .06))
-        self._set_test_item('drag_stop_1', (.49, .06))
-        self._set_test_item('drag_stop_2', (-1.54, .06))
-        self._set_test_item('drag_start_1', (-1.54, .4))
-        self._set_test_item('drag_stop_3', (-1.05, .4))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (35, 60))
+        self._set_test_item('drag_stop_0', (-1.82, .06))
+        self._set_test_item('drag_stop_1', (.49, .06))
+        self._set_test_item('drag_stop_2', (-1.54, .06))
+        self._set_test_item('drag_start_1', (-1.54, .4))
+        self._set_test_item('drag_stop_3', (-1.05, .4))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index d8ed0131f1a7ba3f83d289557fbfe3b8e702e2dd..0d065a14da0846131d8c947ed7e91ae98f806e23 100644 (file)
@@ -44,11 +44,11 @@ class SceneDominoBox(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (65, 60))
-        self._set_test_item('drag_stop_0', (3.21, -.78))
-        self._set_test_item('drag_stop_1', (3.21, .33))
-        self._set_test_item('drag_stop_2', (2.16, 1.87))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._set_test_item('drag_stop_0', (3.21, -.78))
+        self._set_test_item('drag_stop_1', (3.21, .33))
+        self._set_test_item('drag_stop_2', (2.16, 1.87))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index f45048bbe31fbe189700911cd1b3d04efa2a3153..c08ac3a8f9b88de1b9a7ddd1980716530d3a9fba 100644 (file)
@@ -37,16 +37,16 @@ class SceneDominoBoxBasketball(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (65, 60))
-        self._pos_mgr.register('drag_start_1', (30, 60))
-        self._set_test_item('drag_stop_0', (-1.4, -.78))
-        self._set_test_item('drag_stop_1', (-1.26, .2))
-        self._set_test_item('drag_stop_2', (-.28, -.78))
-        self._set_test_item('drag_start_2', (-.28, -.57))
-        self._set_test_item('drag_stop_3', (-.77, -.57))
-        self._set_test_item('drag_start_3', (-.28, -.85))
-        self._set_test_item('drag_stop_4', (-.42, -.85))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (65, 60))
+        self._pos_mgr.register('drag_start_1', (30, 60))
+        self._set_test_item('drag_stop_0', (-1.4, -.78))
+        self._set_test_item('drag_stop_1', (-1.26, .2))
+        self._set_test_item('drag_stop_2', (-.28, -.78))
+        self._set_test_item('drag_start_2', (-.28, -.57))
+        self._set_test_item('drag_stop_3', (-.77, -.57))
+        self._set_test_item('drag_start_3', (-.28, -.85))
+        self._set_test_item('drag_stop_4', (-.42, -.85))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index eeff1b448292768fcd6ef59b025a5d60340609cb..a4e687edae5f31dbb0dde6c0d127d1db5464f89f 100644 (file)
@@ -8,7 +8,7 @@ from pmachines.items.teetertooter import TeeterTooter
 
 class SceneTeeterDominoBoxBasketball(Scene):
 
-    filename = 'assets/scenes/domino_box_basketball.json'
+    filename = 'assets/scenes/teeter_domino_box_basketball.json'
 
     @staticmethod
     def name():
@@ -45,12 +45,12 @@ class SceneTeeterDominoBoxBasketball(Scene):
         self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=.5, pos=(-.1, 0, 1.11))]
         self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 35))
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (60, 60))
-        self._set_test_item('drag_stop_0', (-7.33, 4.24))
-        self._set_test_item('drag_stop_1', (-7.12, 4.24))
-        self._set_test_item('drag_start_1', (-6.77, 4.66))
-        self._set_test_item('drag_stop_2', (-6.77, 4.24))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (60, 60))
+        self._set_test_item('drag_stop_0', (-7.33, 4.24))
+        self._set_test_item('drag_stop_1', (-7.12, 4.24))
+        self._set_test_item('drag_start_1', (-6.77, 4.66))
+        self._set_test_item('drag_stop_2', (-6.77, 4.24))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'
index 7d2f9dd99c2765c7493023bf7abe275747271f98..214826c2fdcb37d0013b1d0e645254abc4e809c6 100644 (file)
@@ -35,12 +35,12 @@ class SceneTeeterTooter(Scene):
         #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
         #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
 
-    def _define_test_items(self):
-        self._pos_mgr.register('drag_start_0', (60, 60))
-        self._set_test_item('drag_stop_0', (-2.65, 1.18))
-        self._set_test_item('drag_stop_1', (-2.65, 3.27))
-        self._set_test_item('drag_start_1', (-2.3, 3.75))
-        self._set_test_item('drag_stop_2', (-2.5, 3.66))
+    def _define_test_items(self):
+        self._pos_mgr.register('drag_start_0', (60, 60))
+        self._set_test_item('drag_stop_0', (-2.65, 1.18))
+        self._set_test_item('drag_stop_1', (-2.65, 3.27))
+        self._set_test_item('drag_start_1', (-2.3, 3.75))
+        self._set_test_item('drag_stop_2', (-2.5, 3.66))
 
     def _instr_txt(self):
         txt = _('Scene: ') + self.name() + '\n\n'