41695bfada782f454c0103c554113885eea4307d
1 from pmachines
.scene
import Scene
2 from pmachines
.items
.box
import Box
3 from pmachines
.items
.shelf
import Shelf
4 from pmachines
.items
.domino
import Domino
, UpStrategy
, DownStrategy
7 class SceneDominoBox(Scene
):
13 return _('Domino and box')
16 self
.items
+= [Box(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, mass
=5, count
=2)]
17 #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
18 self
.items
+= [Shelf(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, mass
=0, pos
=(-.56, 0, .21))]
19 self
.items
+= [Shelf(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, mass
=0, pos
=(1.67, 0, .21))]
20 self
.items
+= [Shelf(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, mass
=0, pos
=(-.56, 0, -1.45))]
21 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))]
22 self
.items
+= [Shelf(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, mass
=0, pos
=(3.78, 0, -1.45))]
23 #self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=9)]
24 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(-.61, 0, -.94), r
=37)]
25 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
26 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(-.06, 0, -.89))]
27 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
28 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(0.91, 0, -.89))]
29 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
30 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(1.73, 0, -.89))]
31 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
32 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(2.57, 0, -.89))]
33 self
.items
[-1].set_strategy(UpStrategy(self
.items
[-1]._np
, 30))
34 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(-.61, 0, .73), r
=37)]
35 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
36 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(-.06, 0, .78))]
37 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
38 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(0.91, 0, .78))]
39 self
.items
[-1].set_strategy(DownStrategy(self
.items
[-1]._np
, 35))
40 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(1.73, 0, .78))]
41 self
.items
[-1].set_strategy(UpStrategy(self
.items
[-1]._np
, 30))
42 self
.items
+= [Domino(self
._world
, self
._mouse
_plane
_node
, self
.cb_inst
, self
.current_bottom
, self
.repos
, pos
=(2.57, 0, .78))]
43 self
.items
[-1].set_strategy(UpStrategy(self
.items
[-1]._np
, 30))
44 #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
45 #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
47 def _define_test_items(self
):
48 self
._pos
_mgr
.register('drag_start_0', (65, 60))
49 self
._set
_test
_item
('drag_stop_0', (3.21, -.78))
50 self
._set
_test
_item
('drag_stop_1', (3.21, .33))
51 self
._set
_test
_item
('drag_stop_2', (2.16, 1.87))
54 txt
= _('Scene: ') + self
.name() + '\n\n'
55 txt
+= _('Goal: only the last piece of each row must be up\n\n')
56 txt
+= _('keep \5mouse_l\5 pressed to drag an item\n\n'
57 'keep \5mouse_r\5 pressed to rotate an item')
60 def _win_condition(self
):
61 return all(itm
.strategy
.win_condition() for itm
in self
.items
) and not self
._paused