ya2 · news · projects · code · about

gettext: --no-location
[pmachines.git] / pmachines / scenes / scene_domino.py
1 from panda3d.core import NodePath
2 from pmachines.scene import Scene
3 from pmachines.items.box import Box
4 from pmachines.items.shelf import Shelf
5 from pmachines.items.domino import Domino, DownStrategy
6 from pmachines.items.basketball import Basketball
7 from pmachines.items.teetertooter import TeeterTooter
8 from ya2.p3d.gfx import P3dGfxMgr
9
10
11 class SceneDomino(Scene):
12
13 @staticmethod
14 def name():
15 return _('Domino')
16
17 def _set_items(self):
18 #self.items += [Box(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
19 #self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
20 self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(-1.2, 0, -.6))]
21 self.items += [Shelf(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, mass=0, pos=(1.2, 0, -.6))]
22 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=2)]
23 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-1.14, 0, -.04))]
24 self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 60))
25 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(-.49, 0, -.04))]
26 self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 60))
27 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(0.94, 0, -.04))]
28 self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 60))
29 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(1.55, 0, -.04))]
30 self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 60))
31 self.items += [Domino(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, pos=(2.09, 0, -.04))]
32 self.items[-1].set_strategy(DownStrategy(self.items[-1]._np, 88))
33 #self.items += [Basketball(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
34 #self.items += [TeeterTooter(self._world, self._mouse_plane_node, self.cb_inst, self.current_bottom, self.repos, count=3)]
35
36 def _define_test_items(self):
37 self._pos_mgr.register('drag_start_0', (35, 60))
38 self._set_test_item('drag_stop_0', (-1.82, .06))
39 self._set_test_item('drag_stop_1', (.49, .06))
40 self._set_test_item('drag_stop_2', (-1.54, .06))
41 self._set_test_item('drag_start_1', (-1.54, .4))
42 self._set_test_item('drag_stop_3', (-1.05, .4))
43
44 def _instr_txt(self):
45 txt = _('Scene: ') + self.name() + '\n\n'
46 txt += _('Goal: every domino piece must fall\n\n')
47 txt += _('keep \5mouse_l\5 pressed to drag an item\n\n'
48 'keep \5mouse_r\5 pressed to rotate an item')
49 return txt
50
51 def _win_condition(self):
52 return all(itm.strategy.win_condition() for itm in self.items) and not self._paused