Up-in-the-Air – commitdiff

You can use Git to clone the repository via the web URL. Download snapshot (zip)
Improvements to word placement in ending cutscene
authorJulian Fietkau <git@fietkau.software>
Sun, 22 Sep 2024 20:37:01 +0000 (22:37 +0200)
committerJulian Fietkau <git@fietkau.software>
Sun, 22 Sep 2024 20:37:01 +0000 (22:37 +0200)
main.js

diff --git a/main.js b/main.js
index 430e36c4996769079da75496a638c980be031be3..8b9601f5e9968c1f665e137cbc5043e73f4795db 100644 (file)
--- a/main.js
+++ b/main.js
@@ -123,7 +123,7 @@ function start(game) {
 function init(game, canvas) {
 
   game.timeProgress = 0;
-  game.timeTotal = 5;
+  game.timeTotal = 258;
   game.courseRadius = 50;
 
   game.objects = {};
@@ -443,6 +443,37 @@ function animate(game, renderer, scene) {
       game.objects.feather.position.setY(-game.courseRadius - 5.4 * Math.min(1, easeInOut(1 - Math.max(0, 4 - game.timeProgress) / 4)));
       game.objects.feather.position.setZ(-6.6 * Math.min(1, easeInOut(1 - Math.max(0, 4 - game.timeProgress) / 4)));
       game.objects.pinwheel.material[4].opacity = easeInOut(Math.max(0, (1 - game.timeProgress)));
+      let letterScale = lerp(0.3, 0.0, easeInOut(Math.max(0, Math.min(1, game.timeProgress - 6))));
+      for(let i = 0; i < game.objects.words.length; i++) {
+        let word = game.objects.words[i];
+        if(!word.collected) {
+          continue;
+        }
+        let x, y, z;
+        let collectionAnimationDuration = 1.0;
+        for(let j = 0; j < word.children.length; j++) {
+          let letter = word.children[j];
+          let wordProgress = j / word.children.length;
+          let animationProgress = (((game.timeProgress + 5 * word.randomAnimOffset) % 5) / 5 + j / 37) % 1;
+          x = game.objects.feather.scale.x * 0.5 * Math.cos(animationProgress * 1 * Math.PI * 2);
+          y = 0.2 * Math.sin(animationProgress * 7 * Math.PI * 2);
+          z = 0.2 * Math.cos(animationProgress * 7 * Math.PI * 2);
+          x = x * Math.cos(game.objects.feather.rotation.z) - y * Math.sin(game.objects.feather.rotation.z);
+          y = y * Math.cos(game.objects.feather.rotation.z) + x * Math.sin(game.objects.feather.rotation.z);
+          x += game.objects.feather.position.x;
+          y += game.objects.feather.position.y;
+          z += game.objects.feather.position.z;
+          if(i == 0 && !word.collected) {
+            // If we don't catch this edge case here, the manually placed first word might be visible
+            // in the closing cutscene if it is not collected.
+            x = 9999;
+          }
+          letter.position.set(x, y, z);
+          let rotation = (game.timeProgress * 3) % (2 * Math.PI);
+          letter.rotation.set(rotation + j, rotation + 2*j, rotation + 3*j);
+          letter.scale.set(letterScale, letterScale, letterScale);
+        }
+      }
       if(game.timeProgress >= 8) {
         game.ui.root.querySelector('.ui-page.title').classList.add('end');
         game.ui.moveToPage('outro', true);