ya2 · news · projects · code · about

intro animation
authorFlavio Calva <f.calva@gmail.com>
Mon, 12 Sep 2022 18:00:42 +0000 (19:00 +0100)
committerFlavio Calva <f.calva@gmail.com>
Mon, 12 Sep 2022 18:00:42 +0000 (19:00 +0100)
pmachines/scene.py
prj.org

index 3751dc919afafdcb30943d6581d551b425b0dcb2..4f1cdbf01254dbcd10e91e99840e86a2420c3f09 100644 (file)
@@ -9,6 +9,8 @@ from direct.gui.OnscreenText import OnscreenText
 from direct.gui.DirectGui import DirectButton, DirectFrame
 from direct.gui.DirectGuiGlobals import FLAT, DISABLED, NORMAL
 from direct.showbase.DirectObject import DirectObject
+from direct.interval.IntervalGlobal import Sequence, Func
+from direct.interval.LerpInterval import LerpFunctionInterval
 from pmachines.items.background import Background
 from pmachines.gui.sidepanel import SidePanel
 from ya2.utils.cursor import MouseCursor
@@ -122,6 +124,7 @@ class Scene(DirectObject):
         info('enforce res: ' + val)
 
     def destroy(self):
+        self.__intro_sequence.finish()
         self.ignore('enforce_res')
         self._unset_gui()
         self._unset_lights()
@@ -139,6 +142,25 @@ class Scene(DirectObject):
     def _set_camera(self):
         base.camera.set_pos(0, -20, 0)
         base.camera.look_at(0, 0, 0)
+        def camera_ani(t):
+            start_v = (1, -5, 1)
+            end_v = (0, -20, 0)
+            curr_pos = (
+                start_v[0] + (end_v[0] - start_v[0]) * t,
+                start_v[1] + (end_v[1] - start_v[1]) * t,
+                start_v[2] + (end_v[2] - start_v[2]) * t)
+            base.camera.set_pos(*curr_pos)
+            self.repos()
+        camera_interval = LerpFunctionInterval(
+            camera_ani,
+            1.2,
+            0,
+            1,
+            blendType='easeInOut')
+        self.__intro_sequence = Sequence(
+            camera_interval,
+            Func(self.repos))
+        self.__intro_sequence.start()
 
     def __load_img_btn(self, path, col):
         img = OnscreenImage('assets/images/buttons/%s.dds' % path)
diff --git a/prj.org b/prj.org
index 1fa3e6bb4fd4237190e6a54aedc11943ab80a480..e609ce419247ba9620ce7be3312b3fb642e647cc 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -3,11 +3,13 @@
 #+CATEGORY: pmachines
 #+TAGS: bug(b) calendar(c) waiting(w)
 
-* READY intro animation (from target item to start position)
-* BACKLOG buttons of the scenes enabled sequentially
+* DOING buttons of the scenes enabled sequentially
 - [ ] each scene has a version
 - [ ] when you win save the id + version
 - [ ] put an "update" if id is saved and versions are different
+* BACKLOG make the editor
+- [ ] a level file is a list of lines: classname posx posy posz rotx roty rotz scalex scaley scalez mass
+- [ ] if you press e: cycle menu (edit object under cursor - edit scene - hide menu)
 * BACKLOG actions: rewind, prev, next
 * BACKLOG teeter-tooter with constraints (real teeter tooter), magnet, road cone, bucket
 * BACKLOG (when python 3.11) use toml in place of ini