ya2 · news · projects · code · about

scene menu
authorFlavio Calva <f.calva@gmail.com>
Thu, 27 Jan 2022 18:06:24 +0000 (19:06 +0100)
committerFlavio Calva <f.calva@gmail.com>
Thu, 27 Jan 2022 18:06:24 +0000 (19:06 +0100)
pmachines/menu.py
pmachines/scene.py
prj.org

index 0fc6accf7f9fdb1136d52cce908e7d41d3cc59ae..091e3d44fb016ac5140eb1cf059248298b502c57 100644 (file)
@@ -9,6 +9,8 @@ from direct.gui.DirectGui import DirectButton, DirectCheckButton, \
 from direct.gui.DirectGuiGlobals import FLAT
 from direct.gui.OnscreenText import OnscreenText
 from lib.engine.gui.cursor import MouseCursor
+from pmachines.scene import Scene
+from panda3d.bullet import BulletWorld
 
 
 class Menu:
@@ -164,6 +166,22 @@ class Menu:
             **self._common_btn)]
 
     def on_play(self):
+        self.destroy()
+        self._widgets = []
+        self._widgets += [DirectButton(
+            text=_('Play'), pos=(0, 1, .1), command=self.start,
+            **self._common_btn | {'frameSize': (-2.4, 2.4, -2.4, 2.4),
+                                  'frameColor': (1, 1, 1, .8)})]
+        s = Scene(BulletWorld(), None, True, None)
+        self._widgets[-1]['frameTexture'] = s.screenshot().make_copy()
+        base.graphicsEngine.renderFrame()
+        base.graphicsEngine.renderFrame()
+        s.destroy()
+        self._widgets += [DirectButton(
+            text=_('Back'), pos=(0, 1, -.8), command=self.on_back,
+            **self._common_btn)]
+
+    def start(self):
         self._fsm.demand('Scene')
 
     def on_options(self):
index 243aec0884ccdbf1c635bb82833024170a4a4cfd..6fdfbd0be847e8b225202a706bf8c948f11fa2dc 100644 (file)
@@ -46,7 +46,7 @@ class Scene(DirectObject):
         self._side_panel = SidePanel(world, self._mouse_plane_node, (-5, 4), (-3, 1), 1, self.items)
         self._scene_tsk = taskMgr.add(self.on_frame, 'on_frame')
 
-    def _screenshot(self, task=None):
+    def screenshot(self, task=None):
         tex = Texture('screenshot')
         buffer = base.win.make_texture_buffer('screenshot', 512, 512, tex, True )
         cam = base.make_camera(buffer)
@@ -69,6 +69,7 @@ class Scene(DirectObject):
         # img = DirectButton(
         #     frameTexture=buffer.get_texture(), relief=FLAT,
         #     frameSize=(-.2, .2, -.2, .2))
+        return buffer.get_texture()
 
     def current_bottom(self):
         curr_bottom = 1
diff --git a/prj.org b/prj.org
index d5640c8db2ef24c6aa1de3abc2a82e1c7582f612..5b762b5d6d3a2cd85148729140fe35c010041d07 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,11 +1,12 @@
 * issues
 * todo
-** menu page for selecting the level
 ** second level (box + shelf)
 ** frame for the end of the level (back, replay, next level)
 ** create one level per item, then levels with more items
 *** e.g. item1, item2, item1+2, item3, item1+2+3, ...
 ** intro animation (from target item to start position)
+** save screenshots of the levels in files (and use them in the menu)
+** use dds files in place of png/jpg
 ** refactoring
 ** build pipeline
 ** version 0.0.yymmdd