Up-in-the-Air – commitdiff

You can use Git to clone the repository via the web URL. Download snapshot (zip)
Pinwheel rotates faster when close to feather
authorJulian Fietkau <git@fietkau.software>
Sat, 5 Oct 2024 22:23:09 +0000 (00:23 +0200)
committerJulian Fietkau <git@fietkau.software>
Sat, 5 Oct 2024 22:23:09 +0000 (00:23 +0200)
main.js

diff --git a/main.js b/main.js
index 3b0511198c1d8e82f0e11ac92405424e3d8810a8..070ad0129ba5c51b04ec90e6191e2c47109b8813 100644 (file)
--- a/main.js
+++ b/main.js
@@ -565,6 +565,7 @@ game['fn'].initializeGame = (canvas) => {
   game.var.featherLocalPos = new THREE.Vector3();
   game.var.featherBorderForce = new THREE.Vector3();
   game.var.pinwheelDistance = new THREE.Vector3();
+  game.var.pinwheelRotationSpeed = 0;
   game.var.notCollectedPos = new THREE.Vector3();
   game.var.collectedPos = new THREE.Vector3();
   game.var.endingEntryTrajectory = new THREE.Vector3();
@@ -753,10 +754,6 @@ game['fn'].animate = (scene) => {
     game.controls.accelY = Math.min(0.0, game.controls.accelY);
   }
 
-  game.objects.pinwheel.rotation.z -= 5 * delta;
-  game.objects.pinwheel.position.x = game.view.camera.position.x + game.controls.positionX;
-  game.objects.pinwheel.position.y = game.view.camera.position.y + game.controls.positionY;
-
   if(game.ui.currentPage != 'gameplay') {
     let cameraSwayFactor = 1;
     if(game.settings['graphics'] == 3) {
@@ -1022,6 +1019,12 @@ game['fn'].animate = (scene) => {
   const tiltedGravity = game.gravity.clone();
   game.var.pinwheelDistance.subVectors(game.objects.feather.position, game.objects.pinwheel.position).setZ(0);
 
+  const pinwheelRotationTargetSpeed = 1 + Math.max(0, 2 - game.var.pinwheelDistance.length());
+  game.var.pinwheelRotationSpeed = Math.max(1, pinwheelRotationTargetSpeed, game.var.pinwheelRotationSpeed - 2 * delta);
+  game.objects.pinwheel.rotation.z -= game.var.pinwheelRotationSpeed * 5 * delta;
+  game.objects.pinwheel.position.x = game.view.camera.position.x + game.controls.positionX;
+  game.objects.pinwheel.position.y = game.view.camera.position.y + game.controls.positionY;
+
   const pinwheelForce = 0.5 * Math.max(0, Math.pow(game.var.pinwheelDistance.length(), - 0.5) - 0.5);
   game['fn'].applyForceToFeather(game.var.pinwheelDistance.normalize().multiplyScalar(pinwheelForce));
   if(pinwheelForce < 0.2) {