diff --git a/src/assets/qml/scene.qml b/src/assets/qml/scene.qml index 03bf994c..6d88716b 100644 --- a/src/assets/qml/scene.qml +++ b/src/assets/qml/scene.qml @@ -1,9 +1,14 @@ import QtQuick -// wowlet ambient scene — dusk sky, tiled grass, and a doge that runs the length -// of the field collecting WOW coins, then loops. All motion gates on -// `scene.reducedMotion` (exposed by the host SceneBackend); frozen it is the -// reduced-motion still. +// wowlet ambient scene — dusk sky, tiled grass, and a doge that runs the field +// collecting WOW coins. All motion gates on `scene.reducedMotion` (exposed by +// the host SceneBackend); frozen it is the reduced-motion still. +// +// One cycle is three beats, so the scene breathes instead of running flat out: +// +// 1. empty field for a few seconds (nothing but sky and grass) +// 2. the coins pop in, one at a time +// 3. the doge and the money go by; the doge collects the coins // // Motion is driven by a unitless 0..1 `runProgress` rather than by animating // straight to `scene.width`: an animation whose `to:` is bound to the width @@ -14,7 +19,13 @@ Rectangle { property bool reducedMotion: (typeof sceneCtx !== 'undefined' && sceneCtx) ? sceneCtx.reducedMotion : false - // Ground plane and the doge's run. + // --- cycle timing ------------------------------------------------------- + readonly property int emptyBeat: 4000 // just background, between laps + readonly property int revealStep: 320 // per coin, popping in one by one + readonly property int settleBeat: 500 // coins all out, before the run + readonly property int runBeat: 8000 // doge + money crossing + + // --- ground plane and the doge's run ------------------------------------ readonly property int grassHeight: 46 readonly property int dogWidth: 104 readonly property int dogHeight: 83 @@ -27,10 +38,12 @@ Rectangle { // The doge collects a coin once its snout reaches the coin's centre. readonly property real snoutX: dogX + dogWidth * 0.78 - // Coins rest on the grass so the run reads as a pickup, not a fly-by. + // --- the coins ---------------------------------------------------------- readonly property int coinSize: 34 readonly property real coinRestY: groundY - coinSize + 8 readonly property int coinCount: Math.max(3, Math.min(7, Math.floor(scene.width / 190))) + // Rises 0 -> coinCount during beat 2; coin `index` is out once it passes index+1. + property real coinReveal: 0.0 gradient: Gradient { GradientStop { position: 0.0; color: "#160d2b" } @@ -46,14 +59,14 @@ Rectangle { color: "#ffe9b0"; opacity: 0.9 } - // Money drifting across the sky, on its own unitless lap. - property real moneyProgress: 0.0 + // Money crosses with the doge, a little quicker, so it leads him off screen. AnimatedImage { source: "qrc:/scene/flyingmoney.gif" playing: !scene.reducedMotion width: 60; height: 55 - y: 4 - x: scene.reducedMotion ? scene.width * 0.30 : -80 + scene.moneyProgress * (scene.width + 160) + y: Math.max(4, Math.min(scene.height * 0.10, 60)) + x: scene.reducedMotion ? scene.width * 0.30 + : -80 + scene.runProgress * (scene.width + 240) opacity: 0.9 } @@ -75,26 +88,29 @@ Rectangle { x: scene.width * (0.22 + 0.66 * (scene.coinCount > 1 ? index / (scene.coinCount - 1) : 0.5)) - width / 2 y: scene.coinRestY - // Purely derived from the run, so a lap reset restores every coin - // with no bookkeeping. - readonly property bool collected: !scene.reducedMotion && scene.snoutX >= x + width / 2 + // Both states are derived from the cycle, so a lap needs no reset + // bookkeeping: `coinReveal` dropping to 0 hides them, and the doge + // returning to the left edge un-collects them. + readonly property bool revealed: scene.reducedMotion || scene.coinReveal >= index + 1 + readonly property bool collected: revealed && !scene.reducedMotion + && scene.snoutX >= x + width / 2 AnimatedImage { id: coinImage width: parent.width; height: parent.height source: "qrc:/scene/goldcoin.gif" - playing: !scene.reducedMotion && !coin.collected - opacity: coin.collected ? 0.0 : 1.0 - scale: coin.collected ? 1.6 : 1.0 + playing: !scene.reducedMotion && coin.revealed && !coin.collected + opacity: (coin.revealed && !coin.collected) ? 1.0 : 0.0 + scale: !coin.revealed ? 0.2 : (coin.collected ? 1.6 : 1.0) // Idle bob, low over the grass. SequentialAnimation on y { - running: !scene.reducedMotion && !coin.collected + running: !scene.reducedMotion && coin.revealed && !coin.collected loops: Animation.Infinite NumberAnimation { to: -11; duration: 950 + index * 130; easing.type: Easing.OutQuad } NumberAnimation { to: 0; duration: 950 + index * 130; easing.type: Easing.InQuad } } - Behavior on opacity { NumberAnimation { duration: 260 } } - Behavior on scale { NumberAnimation { duration: 260; easing.type: Easing.OutBack } } + Behavior on opacity { NumberAnimation { duration: 240 } } + Behavior on scale { NumberAnimation { duration: 300; easing.type: Easing.OutBack } } } // Pickup pop. @@ -128,18 +144,29 @@ Rectangle { x: scene.reducedMotion ? 8 : scene.dogX } - // One lap: run the field, then start over with the coins restored. - NumberAnimation on runProgress { + // The three beats, on a loop. + SequentialAnimation { running: !scene.reducedMotion - from: 0.0; to: 1.0 - duration: 8000 loops: Animation.Infinite - } - NumberAnimation on moneyProgress { - running: !scene.reducedMotion - from: 0.0; to: 1.0 - duration: 13000 - loops: Animation.Infinite + // 1. empty field — doge and money are parked off the left edge by + // runProgress 0, and every coin is hidden. + ScriptAction { script: { scene.runProgress = 0.0; scene.coinReveal = 0.0; } } + PauseAnimation { duration: scene.emptyBeat } + + // 2. coins pop in, one at a time + NumberAnimation { + target: scene; property: "coinReveal" + from: 0.0; to: scene.coinCount + duration: scene.coinCount * scene.revealStep + } + PauseAnimation { duration: scene.settleBeat } + + // 3. the run + NumberAnimation { + target: scene; property: "runProgress" + from: 0.0; to: 1.0 + duration: scene.runBeat + } } }