From 48a8c3613525623a65c7cb03cac0ad592e4bb387 Mon Sep 17 00:00:00 2001 From: jwinterm Date: Mon, 31 Aug 2026 12:48:41 -0400 Subject: [PATCH] =?UTF-8?q?feat(scene):=20give=20the=20loop=20three=20beat?= =?UTF-8?q?s=20=E2=80=94=20empty,=20coins=20pop=20in,=20then=20the=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lap ran flat out and reset the moment the doge left the frame. It now breathes: 1. ~4s of empty field, nothing but sky and grass 2. the coins pop in one at a time (320ms apart) 3. the doge and the money cross, and the doge collects them Both coin states stay derived from the cycle rather than tracked: a coin is out once `coinReveal` passes its index, and collected once the doge's snout reaches its centre. Dropping `coinReveal` to 0 and `runProgress` to 0 at the top of the loop therefore restores the whole field with no reset bookkeeping, and parks the doge and the money off the left edge for the empty beat at the same time. The money now crosses with the doge instead of drifting on its own clock, a little quicker so it leads him off screen, and it sits proportionally in the sky so a tall scene does not pin it to the top edge. Verified by headless qml6 render across a full cycle at 1000x200. --- src/assets/qml/scene.qml | 85 ++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 29 deletions(-) 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 + } } }