From 68a5ffbbdefbbc918e68bfd903f9dba0704897cf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 16 Nov 2026 11:21:30 +0100 Subject: [PATCH 1/3] Bring Moss & Myth to life The woodland figures breathe and sway on a shared clock, and now and then one glances aside or skips. A picked figure starts, stretches and shakes its head while its neighbours turn to look. Moves are leaps: a crouch, an arc that leans into the journey and grows with distance, and a sprung landing. A captured figure waits for its captor, then twirls away. The other sets move as before, and reduced motion stills all of it. Co-Authored-By: Claude Fable 5.2 --- README.md | 2 +- src/BoardView.qml | 15 ++- src/ChessPiece.qml | 187 ++++++++++++++++++++++++++++++++++---- tests/checkmate_tests.cpp | 37 ++++++++ 4 files changed, 222 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 95e6144..ef542ae 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A native 3D chess game for Omarchy, built with C++ and Qt Quick 3D. Play against The sets have individually sculpted pieces: swept metal panels, orbital rings and a crescent queen; carved wood and ivory horses; woodland foxes, owls, acorn sprites and antlered royalty; and glossy candy pieces with curled manes and gold crowns. -Pieces glide into place, knights hop, captures shrink away, and check gets a brief pulse. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. +Pieces glide into place, knights hop, captures shrink away, and check gets a brief pulse. Moss & Myth is alive: its figures breathe and stir, perk up when picked while their neighbours turn to look, and leap to their squares. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. ## Play diff --git a/src/BoardView.qml b/src/BoardView.qml index 3510dfb..0e1dfe8 100644 --- a/src/BoardView.qml +++ b/src/BoardView.qml @@ -21,6 +21,14 @@ Item { property var frames: ["#28343f", "#432b22", "#5b4934", "#f0dccb"] property var accents: ["#dcad62", "#cba265", "#9baa6b", "#dca6ab"] property bool sceneReady: false + // Moss & Myth keeps time for its figures: they breathe, stir and watch one another while the window has the player's attention. + property bool lively: motion && design === 2 + property real clock: 0 + FrameAnimation { running: board.lively; onTriggered: board.clock += frameTime } + Timer { + interval: 1700; repeat: true; running: board.lively + onTriggered: if (Math.random() < .75) figures.objectAt(Math.floor(Math.random() * 32)).fidget() + } Component.onCompleted: Qt.callLater(function() { sceneReady = true }) clip: true focus: true @@ -159,12 +167,15 @@ Item { source: "#Cylinder" visible: parent.target y: 56 - scale: Qt.vector3d(.23,1.1,.23) + // Woodland markers swell and settle like something growing. + property real swell: board.lively && visible ? .23 * (1 + .09 * Math.sin(board.clock * 3.1 + tile.index)) : .23 + scale: Qt.vector3d(swell,1.1,swell) materials: PrincipledMaterial { baseColor: board.accents[board.design]; opacity: .8; lighting: PrincipledMaterial.NoLighting } } } } Repeater3D { + id: figures model: 32 ChessPiece { required property int index @@ -173,6 +184,8 @@ Item { design: board.design seat: board.seat motion: board.motion + clock: board.clock + attention: backend.selected selected: backend.selected === record.square && record.alive } } diff --git a/src/ChessPiece.qml b/src/ChessPiece.qml index 770376e..22fc8f3 100644 --- a/src/ChessPiece.qml +++ b/src/ChessPiece.qml @@ -29,39 +29,129 @@ Node { property vector3d sugarGlow: !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.24,.085,.095) : Qt.vector3d(.105,.05,.125) property vector3d secondGlow: design === 0 ? (record.white ? Qt.vector3d(.22,.95,1.05) : Qt.vector3d(1.25,.55,.08)) : !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.15,.03,.06) : Qt.vector3d(.06,.025,.1) - x: record.square % 8 - 3.5 - z: 3.5 - Math.floor(record.square / 8) - y: .12 + lift + (selected ? .1 : 0) - scale: Qt.vector3d(presence, presence, presence) + // Moss & Myth is alive: its figures breathe, perk up when chosen, watch a neighbour being picked, and leap rather than slide. + required property real clock + required property int attention + property int square: record.square + // Where the figure stands. It follows `square` by hand so a leap is measured before the slide starts. + property int place: 0 + property int travel: 360 + property real raise: selected ? (woodland ? .17 : .1) : 0 + property real stretch: 1 + property real lean: 0 + property real leanX: 0 + property real leanZ: 0 + property real wiggle: 0 + property real vigor: woodland && motion ? 1 : 0 + // A tree stump stirs far less than the creatures around it. + property real liveliness: record.kind === 4 ? .3 : 1 + property real phase: pieceId * 2.399 + property real breath: vigor * liveliness * Math.sin(clock * (1.5 + pieceId % 5 * .11) + phase) + property real tall: stretch * (1 + .011 * breath * (1 + raise * 6)) + property real wide: 1 + (1 - tall) * .6 // Every figure faces whoever is seated at the board. Knights turn in toward its middle: the foxes // a little, the horses far enough to show their profile. property real knightTurn: woodland ? 32 : 58 - eulerRotation.y: 180 + seat + (record.kind === 2 ? (pieceId % 2 ? knightTurn : -knightTurn) * Math.cos(seat * Math.PI / 180) : 0) - Behavior on x { id: xBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: slideX; duration: 360; easing.type: Easing.InOutCubic } } - Behavior on z { id: zBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: slideZ; duration: 360; easing.type: Easing.InOutCubic } } - Behavior on y { id: yBehavior; enabled: piece.ready && piece.motion && !hop.running; NumberAnimation { id: selectionLift; duration: 180; easing.type: Easing.OutCubic } } - Behavior on presence { id: presenceBehavior; enabled: piece.ready && piece.motion; NumberAnimation { id: captureShrink; duration: 220; easing.type: Easing.InCubic } } + property real facing: 180 + seat + (record.kind === 2 ? (pieceId % 2 ? knightTurn : -knightTurn) * Math.cos(seat * Math.PI / 180) : 0) + // Neighbours turn part of the way toward the figure in hand; one standing behind them is left alone. + property real look: regard() + function regard() { + if (!woodland || !motion || attention < 0 || selected || !record.alive) return 0 + let dx = attention % 8 - place % 8, dz = Math.floor(place / 8) - Math.floor(attention / 8) + let reach = Math.hypot(dx, dz) + if (reach < .5 || reach > 3.3) return 0 + return 20 * liveliness * Math.sin(Math.atan2(-dx, -dz) - facing * Math.PI / 180) * Math.min(1, (3.3 - reach) / 2) + } + x: place % 8 - 3.5 + z: 3.5 - Math.floor(place / 8) + y: .12 + lift + raise * (1 + vigor * .1 * Math.sin(clock * 3.1 + phase)) + scale: Qt.vector3d(presence * wide, presence * tall, presence * wide) + // A captured woodland figure twirls as it goes. + eulerRotation.y: facing + wiggle + look + vigor * liveliness * 1.2 * Math.sin(clock * .7 + phase * 1.7) + (woodland ? (1 - presence) * 160 : 0) + eulerRotation.x: lean * leanZ + eulerRotation.z: -lean * leanX + Behavior on x { + id: xBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.woodland ? 70 : 0 } + NumberAnimation { duration: piece.travel; easing.type: piece.woodland ? Easing.InOutSine : Easing.InOutCubic } + } + } + Behavior on z { + id: zBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.woodland ? 70 : 0 } + NumberAnimation { duration: piece.travel; easing.type: piece.woodland ? Easing.InOutSine : Easing.InOutCubic } + } + } + Behavior on raise { + id: raiseBehavior; enabled: piece.ready && piece.motion + NumberAnimation { duration: piece.woodland ? 300 : 180; easing.type: piece.woodland && piece.selected ? Easing.OutBack : Easing.OutCubic } + } + Behavior on look { + id: lookBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.pieceId * 53 % 140 } + NumberAnimation { duration: 380; easing.type: Easing.OutBack } + } + } + // The captured figure waits for its captor to arrive. + Behavior on presence { + id: presenceBehavior; enabled: piece.ready && piece.motion + SequentialAnimation { + PauseAnimation { duration: piece.woodland && !piece.record.alive ? 240 : 0 } + NumberAnimation { duration: piece.woodland ? 300 : 220; easing.type: Easing.InCubic } + } + } onMotionChanged: { if (!motion) { xBehavior.enabled = false; zBehavior.enabled = false - yBehavior.enabled = false; presenceBehavior.enabled = false - hop.stop(); lift = 0 + raiseBehavior.enabled = false; lookBehavior.enabled = false; presenceBehavior.enabled = false + hop.stop(); leap.stop(); perk.stop(); glance.stop(); skip.stop() + lift = 0; stretch = 1; lean = 0; wiggle = 0 // Resolve moves queued before the first animation frame as well. - x = Qt.binding(function() { return piece.record.square % 8 - 3.5 }) - z = Qt.binding(function() { return 3.5 - Math.floor(piece.record.square / 8) }) - y = Qt.binding(function() { return .12 + piece.lift + (piece.selected ? .1 : 0) }) + x = Qt.binding(function() { return piece.place % 8 - 3.5 }) + z = Qt.binding(function() { return 3.5 - Math.floor(piece.place / 8) }) + raise = Qt.binding(function() { return piece.selected ? (piece.woodland ? .17 : .1) : 0 }) + look = Qt.binding(function() { return piece.regard() }) presence = Qt.binding(function() { return piece.record.alive ? 1 : 0 }) xBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) zBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) - yBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion && !hop.running }) + raiseBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) + lookBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) presenceBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) } } - Component.onCompleted: ready = true + onSquareChanged: { + if (ready && motion && woodland && record.alive) { + let dx = square % 8 - 3.5 - x, dz = 3.5 - Math.floor(square / 8) - z, reach = Math.hypot(dx, dz) + if (reach > .01) { + // Further is slower and higher; foxes clear whatever stands between. + travel = Math.min(620, 300 + 50 * reach) + leap.height = record.kind === 2 ? .55 : Math.min(.36, .12 + .04 * reach) + // The figure leans along its path, which is turned into its own frame. + let turn = eulerRotation.y * Math.PI / 180 + leanX = (dx * Math.cos(turn) - dz * Math.sin(turn)) / reach + leanZ = (dx * Math.sin(turn) + dz * Math.cos(turn)) / reach + perk.stop(); skip.stop() + leap.restart() + } + } else travel = 360 + place = square + } + onSelectedChanged: if (selected && woodland && motion && ready) { skip.stop(); glance.stop(); perk.restart() } + Component.onCompleted: { place = square; ready = true } + // Now and then the board asks an idle figure to stir: a look to one side, or a small skip from the young and the foxes. + function fidget() { + if (!woodland || !motion || !record.alive || record.kind === 4 || selected || look !== 0) return + if (leap.running || perk.running || glance.running || skip.running) return + if (record.kind <= 2 && Math.random() < .4) skip.restart() + else { glance.side = Math.random() < .5 ? -1 : 1; glance.restart() } + } Connections { target: backend function onMoved(id, knight, capture) { - if (id === piece.pieceId && piece.motion) { + if (id === piece.pieceId && piece.motion && !piece.woodland) { hop.height = knight ? .48 : .14 hop.restart() } @@ -74,6 +164,69 @@ Node { NumberAnimation { target: piece; property: "lift"; to: hop.height; duration: 150; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "lift"; to: 0; duration: 210; easing.type: Easing.InOutQuad } } + // A crouch, an arc leaning into the journey, and a soft landing that springs back. + SequentialAnimation { + id: leap + objectName: "leap" + property real height: .2 + NumberAnimation { target: piece; property: "stretch"; to: .9; duration: 70; easing.type: Easing.OutQuad } + ParallelAnimation { + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: leap.height; duration: piece.travel * .5; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: piece.travel * .5; easing.type: Easing.InQuad } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: 1.07; duration: piece.travel * .3; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.travel * .7 } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "lean"; to: 9; duration: piece.travel * .35; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lean"; to: -5; duration: piece.travel * .65; easing.type: Easing.InOutQuad } + } + } + ParallelAnimation { + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: .88; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 320; easing.type: Easing.OutBack } + } + NumberAnimation { target: piece; property: "lean"; to: 0; duration: 280; easing.type: Easing.OutBack } + } + } + // Picked up: a start, a stretch, and a shake of the head. + ParallelAnimation { + id: perk + objectName: "perk" + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: .93; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1.08; duration: 150; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 260; easing.type: Easing.OutBack } + } + SequentialAnimation { + PauseAnimation { duration: 120 } + NumberAnimation { target: piece; property: "wiggle"; to: 9; duration: 110; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: -7; duration: 150; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: 220; easing.type: Easing.OutBack } + } + } + SequentialAnimation { + id: glance + property int side: 1 + NumberAnimation { target: piece; property: "wiggle"; to: glance.side * 15; duration: 380; easing.type: Easing.InOutSine } + PauseAnimation { duration: 500 } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: 520; easing.type: Easing.InOutSine } + } + ParallelAnimation { + id: skip + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: .07; duration: 130; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 170; easing.type: Easing.InQuad } + } + SequentialAnimation { + NumberAnimation { target: piece; property: "stretch"; to: 1.05; duration: 130 } + NumberAnimation { target: piece; property: "stretch"; to: .94; duration: 170 } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 240; easing.type: Easing.OutBack } + } + } Model { objectName: "piece-" + piece.pieceId property int boardSquare: piece.record.square diff --git a/tests/checkmate_tests.cpp b/tests/checkmate_tests.cpp index b38e9f8..01a2f9c 100644 --- a/tests/checkmate_tests.cpp +++ b/tests/checkmate_tests.cpp @@ -836,6 +836,43 @@ private slots: QCOMPARE(pawn->property("lift").toDouble(),0.0); QCOMPARE(pawn->property("z").toDouble(),.5); + // Moss & Myth is alive: it breathes, perks up in the hand, draws its neighbours' eyes, and leaps. + backend.newGame(false,0); + backend.setPieceSet(2); + backend.setReducedMotion(false); + QTRY_VERIFY(board->property("clock").toDouble()>0); + QTRY_VERIFY(qAbs(pawn->property("tall").toDouble()-1)>.002); + auto *neighbour=window->findChild("figure-"+QString::number(backend.position().board[11].id)); + auto *leap=pawn->findChild("leap"); + auto *perk=pawn->findChild("perk"); + QVERIFY(neighbour && leap && perk); + backend.selectSquare(12); + QVERIFY(perk->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-.17)<.001); + QTRY_VERIFY(qAbs(neighbour->property("look").toDouble())>5); + QVERIFY(backend.move(12,28)); + QVERIFY(leap->property("running").toBool()); + QVERIFY(!hop->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); + QVERIFY(pawn->property("lift").toDouble()>0); + QTRY_VERIFY_WITH_TIMEOUT(!leap->property("running").toBool(),2000); + QVERIFY(qFuzzyCompare(pawn->property("z").toFloat(),.5f)); + QCOMPARE(pawn->property("lean").toDouble(),0.0); + QCOMPARE(pawn->property("stretch").toDouble(),1.0); + QTRY_COMPARE(neighbour->property("look").toDouble(),0.0); + // Reduced motion stills a leap in flight and every idle stir with it. + backend.undo(); + QVERIFY(leap->property("running").toBool()); + backend.selectSquare(11); + backend.setReducedMotion(true); + QVERIFY(!leap->property("running").toBool()); + QCOMPARE(pawn->property("tall").toDouble(),1.0); + QCOMPARE(pawn->property("look").toDouble(),0.0); + QCOMPARE(pawn->property("z").toDouble(),2.5); + QCOMPARE(pawn->property("y").toFloat(),.12f); + QCOMPARE(neighbour->property("y").toFloat(),.29f); + backend.setPieceSet(3); + backend.newGame(false,0); QTest::qWait(100); auto *scene=window->findChild("scene"); From e5912771f5dc2786e854323f9ee623bfe071abf3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 16 Nov 2026 11:31:24 +0100 Subject: [PATCH 2/3] Give every set its own manner of moving The woodland animation is now a table of motion parameters per set, so each board is alive in character. Orbital craft hover with pulsing lights, bank into a glide, dip on arrival and scan when chosen. Midnight Atelier's pieces are handled under a flickering flame: tilted in the fingers, carried over, set down with a rock, and tipped over when taken. Candy Kingdom's sweets wobble like jelly, warm in the hand and pop. One journey animation replaces the old hop, with distance setting its length and height, and captures everywhere wait for the captor. Co-Authored-By: Claude Fable 5.2 --- README.md | 2 +- src/BoardView.qml | 10 ++- src/ChessPiece.qml | 159 +++++++++++++++++++++----------------- tests/checkmate_tests.cpp | 43 ++++++++--- 4 files changed, 129 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index ef542ae..7b8cce5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A native 3D chess game for Omarchy, built with C++ and Qt Quick 3D. Play against The sets have individually sculpted pieces: swept metal panels, orbital rings and a crescent queen; carved wood and ivory horses; woodland foxes, owls, acorn sprites and antlered royalty; and glossy candy pieces with curled manes and gold crowns. -Pieces glide into place, knights hop, captures shrink away, and check gets a brief pulse. Moss & Myth is alive: its figures breathe and stir, perk up when picked while their neighbours turn to look, and leap to their squares. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. +Every set moves in its own manner. Orbital craft hover over their squares with pulsing lights, bank into a glide and scan when chosen. Midnight Atelier's pieces are handled under flickering candlelight: tilted in unseen fingers, set down with a rock, and tipped over when taken. Moss & Myth's creatures breathe and stir, turn to watch a neighbour being picked, and leap. Candy Kingdom's sweets wobble like jelly and pop. Knights jump highest everywhere, and check gets a brief pulse. Reduced motion is available in Settings. The interface follows Omarchy's theme and language; the board's materials follow the selected set. ## Play diff --git a/src/BoardView.qml b/src/BoardView.qml index 0e1dfe8..ed5f2ec 100644 --- a/src/BoardView.qml +++ b/src/BoardView.qml @@ -21,8 +21,10 @@ Item { property var frames: ["#28343f", "#432b22", "#5b4934", "#f0dccb"] property var accents: ["#dcad62", "#cba265", "#9baa6b", "#dca6ab"] property bool sceneReady: false - // Moss & Myth keeps time for its figures: they breathe, stir and watch one another while the window has the player's attention. - property bool lively: motion && design === 2 + // The board keeps time for its figures, which hover, breathe, stir and watch one another while the window has the player's attention. + property bool lively: motion + // Midnight Atelier is lit by a flame, which is never quite steady. + property real flicker: lively && design === 1 ? .04 * Math.sin(clock * 7.3) * Math.sin(clock * 2.1) + .018 * Math.sin(clock * 13.7) : 0 property real clock: 0 FrameAnimation { running: board.lively; onTriggered: board.clock += frameTime } Timer { @@ -115,7 +117,7 @@ Item { DirectionalLight { eulerRotation: Qt.vector3d(-45,-35,0) color: "#ffebd2" - brightness: 1.05 + brightness: 1.05 * (1 + board.flicker) castsShadow: true shadowMapQuality: Light.ShadowMapQualityHigh shadowFactor: 80 @@ -167,7 +169,7 @@ Item { source: "#Cylinder" visible: parent.target y: 56 - // Woodland markers swell and settle like something growing. + // Markers swell and settle so the way forward is never static. property real swell: board.lively && visible ? .23 * (1 + .09 * Math.sin(board.clock * 3.1 + tile.index)) : .23 scale: Qt.vector3d(swell,1.1,swell) materials: PrincipledMaterial { baseColor: board.accents[board.design]; opacity: .8; lighting: PrincipledMaterial.NoLighting } diff --git a/src/ChessPiece.qml b/src/ChessPiece.qml index 22fc8f3..6e5f2a9 100644 --- a/src/ChessPiece.qml +++ b/src/ChessPiece.qml @@ -29,26 +29,53 @@ Node { property vector3d sugarGlow: !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.24,.085,.095) : Qt.vector3d(.105,.05,.125) property vector3d secondGlow: design === 0 ? (record.white ? Qt.vector3d(.22,.95,1.05) : Qt.vector3d(1.25,.55,.08)) : !candy ? Qt.vector3d(0,0,0) : record.white ? Qt.vector3d(.15,.03,.06) : Qt.vector3d(.06,.025,.1) - // Moss & Myth is alive: its figures breathe, perk up when chosen, watch a neighbour being picked, and leap rather than slide. + // Each set moves in its own manner. Orbital craft hover, bank into a glide and scan with their lights up. Atelier's pieces + // are handled: tilted in unseen fingers, carried over, set down with a rock, and tipped over when taken. The woodland + // creatures breathe, look and leap. The sweets wobble like jelly and pop. required property real clock required property int attention + readonly property var manners: [ + { breath: 0, bulge: 0, sway: 0, hover: .035, drift: .02, raise: .2, raiseTime: 380, spring: false, bob: .06, pinch: 0, + windup: 0, crouch: 1, stretch: 1, squash: 1, lean: 11, counter: -6, dip: .03, settle: Easing.OutCubic, settleTime: 320, glide: Easing.InOutCubic, + arc: .04, arcPer: .01, arcMax: .1, knightArc: .45, pace: 340, pacePer: 60, start: 1, reach: 1, shake: 20, shakeTime: 170, + look: 9, glance: 14, skip: 0, fade: 320, pop: false, twirl: 0, topple: 0 }, + { breath: 0, bulge: 0, sway: 0, hover: 0, drift: 0, raise: .14, raiseTime: 220, spring: false, bob: 0, pinch: 3.5, + windup: 0, crouch: 1, stretch: 1, squash: 1, lean: 5, counter: -4, dip: 0, settle: Easing.OutElastic, settleTime: 650, glide: Easing.InOutCubic, + arc: .16, arcPer: .03, arcMax: .34, knightArc: .5, pace: 320, pacePer: 45, start: 1, reach: 1, shake: 0, shakeTime: 100, + look: 0, glance: 0, skip: 0, fade: 380, pop: false, twirl: 0, topple: 80 }, + { breath: .011, bulge: .6, sway: 1.2, hover: 0, drift: 0, raise: .17, raiseTime: 300, spring: true, bob: .1, pinch: 0, + windup: 70, crouch: .9, stretch: 1.07, squash: .88, lean: 9, counter: -5, dip: 0, settle: Easing.OutBack, settleTime: 320, glide: Easing.InOutSine, + arc: .12, arcPer: .04, arcMax: .36, knightArc: .55, pace: 300, pacePer: 50, start: .93, reach: 1.08, shake: 9, shakeTime: 110, + look: 20, glance: 15, skip: .07, fade: 300, pop: false, twirl: 160, topple: 0 }, + { breath: .014, bulge: .9, sway: .6, hover: 0, drift: 0, raise: .17, raiseTime: 320, spring: true, bob: .12, pinch: 0, + windup: 80, crouch: .84, stretch: 1.1, squash: .8, lean: 6, counter: -3, dip: 0, settle: Easing.OutElastic, settleTime: 560, glide: Easing.InOutSine, + arc: .16, arcPer: .04, arcMax: .4, knightArc: .6, pace: 320, pacePer: 50, start: .88, reach: 1.13, shake: 0, shakeTime: 100, + look: 12, glance: 0, skip: .05, fade: 280, pop: true, twirl: 0, topple: 0 } + ] + readonly property var manner: manners[design] property int square: record.square - // Where the figure stands. It follows `square` by hand so a leap is measured before the slide starts. + // Where the figure stands. It follows `square` by hand so a journey is measured before the slide starts. property int place: 0 property int travel: 360 - property real raise: selected ? (woodland ? .17 : .1) : 0 + property real raise: selected ? manner.raise : 0 + property real held: raise / manner.raise property real stretch: 1 property real lean: 0 property real leanX: 0 property real leanZ: 0 property real wiggle: 0 - property real vigor: woodland && motion ? 1 : 0 + // Idle life pauses with the clock when the window is left, and is gone altogether under reduced motion. + property real vigor: backend.reducedMotion ? 0 : 1 // A tree stump stirs far less than the creatures around it. - property real liveliness: record.kind === 4 ? .3 : 1 + property real liveliness: woodland && record.kind === 4 ? .3 : 1 property real phase: pieceId * 2.399 property real breath: vigor * liveliness * Math.sin(clock * (1.5 + pieceId % 5 * .11) + phase) - property real tall: stretch * (1 + .011 * breath * (1 + raise * 6)) - property real wide: 1 + (1 - tall) * .6 + property real tall: stretch * (1 + manner.breath * breath * (1 + raise * 6)) + property real wide: 1 + (1 - tall) * manner.bulge + // A piece in the fingers tips toward the player and is never held quite still. + property real tilt: held * manner.pinch * (1 + vigor * .35 * Math.sin(clock * 1.7 + phase)) + // Orbital lights idle at a slow pulse, come up in the hand and when a neighbour is chosen, and go out with a capture. + property real pulse: design === 0 ? presence * (1 + vigor * .2 * Math.sin(clock * 1.3 + phase) + held * .9 + Math.abs(look) / 18) : 1 // Every figure faces whoever is seated at the board. Knights turn in toward its middle: the foxes // a little, the horses far enough to show their profile. property real knightTurn: woodland ? 32 : 58 @@ -56,63 +83,63 @@ Node { // Neighbours turn part of the way toward the figure in hand; one standing behind them is left alone. property real look: regard() function regard() { - if (!woodland || !motion || attention < 0 || selected || !record.alive) return 0 + if (!motion || attention < 0 || selected || !record.alive) return 0 let dx = attention % 8 - place % 8, dz = Math.floor(place / 8) - Math.floor(attention / 8) let reach = Math.hypot(dx, dz) if (reach < .5 || reach > 3.3) return 0 - return 20 * liveliness * Math.sin(Math.atan2(-dx, -dz) - facing * Math.PI / 180) * Math.min(1, (3.3 - reach) / 2) + return manner.look * liveliness * Math.sin(Math.atan2(-dx, -dz) - facing * Math.PI / 180) * Math.min(1, (3.3 - reach) / 2) } x: place % 8 - 3.5 z: 3.5 - Math.floor(place / 8) - y: .12 + lift + raise * (1 + vigor * .1 * Math.sin(clock * 3.1 + phase)) + y: .12 + manner.hover + vigor * manner.drift * Math.sin(clock * .9 + phase) + lift + raise * (1 + vigor * manner.bob * Math.sin(clock * 3.1 + phase)) scale: Qt.vector3d(presence * wide, presence * tall, presence * wide) - // A captured woodland figure twirls as it goes. - eulerRotation.y: facing + wiggle + look + vigor * liveliness * 1.2 * Math.sin(clock * .7 + phase * 1.7) + (woodland ? (1 - presence) * 160 : 0) - eulerRotation.x: lean * leanZ - eulerRotation.z: -lean * leanX + // A captured woodland figure twirls as it goes; a captured Atelier piece is tipped onto its side. + eulerRotation.y: facing + wiggle + look + vigor * liveliness * manner.sway * Math.sin(clock * .7 + phase * 1.7) + (1 - presence) * manner.twirl + eulerRotation.x: lean * leanZ + tilt + eulerRotation.z: -lean * leanX + Math.min(1, (1 - presence) * 2.2) * manner.topple * (pieceId % 2 ? 1 : -1) Behavior on x { id: xBehavior; enabled: piece.ready && piece.motion SequentialAnimation { - PauseAnimation { duration: piece.woodland ? 70 : 0 } - NumberAnimation { duration: piece.travel; easing.type: piece.woodland ? Easing.InOutSine : Easing.InOutCubic } + PauseAnimation { duration: piece.manner.windup } + NumberAnimation { duration: piece.travel; easing.type: piece.manner.glide } } } Behavior on z { id: zBehavior; enabled: piece.ready && piece.motion SequentialAnimation { - PauseAnimation { duration: piece.woodland ? 70 : 0 } - NumberAnimation { duration: piece.travel; easing.type: piece.woodland ? Easing.InOutSine : Easing.InOutCubic } + PauseAnimation { duration: piece.manner.windup } + NumberAnimation { duration: piece.travel; easing.type: piece.manner.glide } } } Behavior on raise { id: raiseBehavior; enabled: piece.ready && piece.motion - NumberAnimation { duration: piece.woodland ? 300 : 180; easing.type: piece.woodland && piece.selected ? Easing.OutBack : Easing.OutCubic } + NumberAnimation { duration: piece.manner.raiseTime; easing.type: piece.manner.spring && piece.selected ? Easing.OutBack : Easing.OutCubic } } Behavior on look { id: lookBehavior; enabled: piece.ready && piece.motion SequentialAnimation { PauseAnimation { duration: piece.pieceId * 53 % 140 } - NumberAnimation { duration: 380; easing.type: Easing.OutBack } + NumberAnimation { duration: 380; easing.type: piece.manner.spring ? Easing.OutBack : Easing.InOutCubic } } } - // The captured figure waits for its captor to arrive. + // The captured figure waits for its captor to arrive. A sweet swells before it pops. Behavior on presence { id: presenceBehavior; enabled: piece.ready && piece.motion SequentialAnimation { - PauseAnimation { duration: piece.woodland && !piece.record.alive ? 240 : 0 } - NumberAnimation { duration: piece.woodland ? 300 : 220; easing.type: Easing.InCubic } + PauseAnimation { duration: piece.record.alive ? 0 : 240 } + NumberAnimation { duration: piece.manner.fade; easing.type: piece.manner.pop && !piece.record.alive ? Easing.InBack : Easing.InCubic } } } onMotionChanged: { if (!motion) { xBehavior.enabled = false; zBehavior.enabled = false raiseBehavior.enabled = false; lookBehavior.enabled = false; presenceBehavior.enabled = false - hop.stop(); leap.stop(); perk.stop(); glance.stop(); skip.stop() + leap.stop(); perk.stop(); glance.stop(); skip.stop() lift = 0; stretch = 1; lean = 0; wiggle = 0 // Resolve moves queued before the first animation frame as well. x = Qt.binding(function() { return piece.place % 8 - 3.5 }) z = Qt.binding(function() { return 3.5 - Math.floor(piece.place / 8) }) - raise = Qt.binding(function() { return piece.selected ? (piece.woodland ? .17 : .1) : 0 }) + raise = Qt.binding(function() { return piece.selected ? piece.manner.raise : 0 }) look = Qt.binding(function() { return piece.regard() }) presence = Qt.binding(function() { return piece.record.alive ? 1 : 0 }) xBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) @@ -123,12 +150,12 @@ Node { } } onSquareChanged: { - if (ready && motion && woodland && record.alive) { + if (ready && motion && record.alive) { let dx = square % 8 - 3.5 - x, dz = 3.5 - Math.floor(square / 8) - z, reach = Math.hypot(dx, dz) if (reach > .01) { - // Further is slower and higher; foxes clear whatever stands between. - travel = Math.min(620, 300 + 50 * reach) - leap.height = record.kind === 2 ? .55 : Math.min(.36, .12 + .04 * reach) + // Further is slower and higher; knights clear whatever stands between. + travel = Math.min(manner.pace + 320, manner.pace + manner.pacePer * reach) + leap.height = record.kind === 2 ? manner.knightArc : Math.min(manner.arcMax, manner.arc + manner.arcPer * reach) // The figure leans along its path, which is turned into its own frame. let turn = eulerRotation.y * Math.PI / 180 leanX = (dx * Math.cos(turn) - dz * Math.sin(turn)) / reach @@ -136,95 +163,84 @@ Node { perk.stop(); skip.stop() leap.restart() } - } else travel = 360 + } place = square } - onSelectedChanged: if (selected && woodland && motion && ready) { skip.stop(); glance.stop(); perk.restart() } + onSelectedChanged: if (selected && motion && ready) { skip.stop(); glance.stop(); perk.restart() } Component.onCompleted: { place = square; ready = true } - // Now and then the board asks an idle figure to stir: a look to one side, or a small skip from the young and the foxes. + // Now and then the board asks an idle figure to stir: a look to one side, or a small skip from the sweets, the young and the foxes. function fidget() { - if (!woodland || !motion || !record.alive || record.kind === 4 || selected || look !== 0) return + if (!motion || !record.alive || liveliness < 1 || selected || look !== 0) return if (leap.running || perk.running || glance.running || skip.running) return - if (record.kind <= 2 && Math.random() < .4) skip.restart() - else { glance.side = Math.random() < .5 ? -1 : 1; glance.restart() } - } - Connections { - target: backend - function onMoved(id, knight, capture) { - if (id === piece.pieceId && piece.motion && !piece.woodland) { - hop.height = knight ? .48 : .14 - hop.restart() - } - } + if (manner.skip > 0 && (manner.glance === 0 || (record.kind <= 2 && Math.random() < .4))) skip.restart() + else if (manner.glance > 0) { glance.side = Math.random() < .5 ? -1 : 1; glance.restart() } } - SequentialAnimation { - id: hop - objectName: "moveHop" - property real height: .15 - NumberAnimation { target: piece; property: "lift"; to: hop.height; duration: 150; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "lift"; to: 0; duration: 210; easing.type: Easing.InOutQuad } - } - // A crouch, an arc leaning into the journey, and a soft landing that springs back. + // The journey: a crouch where the set has one, an arc leaning into the way ahead, and a landing that settles in character. SequentialAnimation { id: leap objectName: "leap" property real height: .2 - NumberAnimation { target: piece; property: "stretch"; to: .9; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.crouch; duration: piece.manner.windup; easing.type: Easing.OutQuad } ParallelAnimation { SequentialAnimation { NumberAnimation { target: piece; property: "lift"; to: leap.height; duration: piece.travel * .5; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "lift"; to: 0; duration: piece.travel * .5; easing.type: Easing.InQuad } } SequentialAnimation { - NumberAnimation { target: piece; property: "stretch"; to: 1.07; duration: piece.travel * .3; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.stretch; duration: piece.travel * .3; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.travel * .7 } } SequentialAnimation { - NumberAnimation { target: piece; property: "lean"; to: 9; duration: piece.travel * .35; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "lean"; to: -5; duration: piece.travel * .65; easing.type: Easing.InOutQuad } + NumberAnimation { target: piece; property: "lean"; to: piece.manner.lean; duration: piece.travel * .35; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lean"; to: piece.manner.counter; duration: piece.travel * .65; easing.type: Easing.InOutQuad } } } ParallelAnimation { SequentialAnimation { - NumberAnimation { target: piece; property: "stretch"; to: .88; duration: 70; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 320; easing.type: Easing.OutBack } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.squash; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } + } + NumberAnimation { target: piece; property: "lean"; to: 0; duration: piece.manner.settleTime; easing.type: piece.manner.settle } + // A hovering craft sinks a little under its own arrival. + SequentialAnimation { + NumberAnimation { target: piece; property: "lift"; to: -piece.manner.dip; duration: 130; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 260; easing.type: Easing.InOutQuad } } - NumberAnimation { target: piece; property: "lean"; to: 0; duration: 280; easing.type: Easing.OutBack } } } - // Picked up: a start, a stretch, and a shake of the head. + // Picked up: a start and a stretch, then a shake of the head or a scan to either side. ParallelAnimation { id: perk objectName: "perk" SequentialAnimation { - NumberAnimation { target: piece; property: "stretch"; to: .93; duration: 70; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "stretch"; to: 1.08; duration: 150; easing.type: Easing.OutQuad } - NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 260; easing.type: Easing.OutBack } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.start; duration: 70; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: piece.manner.reach; duration: 150; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } } SequentialAnimation { PauseAnimation { duration: 120 } - NumberAnimation { target: piece; property: "wiggle"; to: 9; duration: 110; easing.type: Easing.InOutSine } - NumberAnimation { target: piece; property: "wiggle"; to: -7; duration: 150; easing.type: Easing.InOutSine } - NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: 220; easing.type: Easing.OutBack } + NumberAnimation { target: piece; property: "wiggle"; to: piece.manner.shake; duration: piece.manner.shakeTime; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: -piece.manner.shake * .8; duration: piece.manner.shakeTime * 1.4; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: piece.manner.shakeTime * 2; easing.type: piece.manner.spring ? Easing.OutBack : Easing.InOutCubic } } } SequentialAnimation { id: glance property int side: 1 - NumberAnimation { target: piece; property: "wiggle"; to: glance.side * 15; duration: 380; easing.type: Easing.InOutSine } + NumberAnimation { target: piece; property: "wiggle"; to: glance.side * piece.manner.glance; duration: 380; easing.type: Easing.InOutSine } PauseAnimation { duration: 500 } NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: 520; easing.type: Easing.InOutSine } } ParallelAnimation { id: skip SequentialAnimation { - NumberAnimation { target: piece; property: "lift"; to: .07; duration: 130; easing.type: Easing.OutQuad } + NumberAnimation { target: piece; property: "lift"; to: piece.manner.skip; duration: 130; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "lift"; to: 0; duration: 170; easing.type: Easing.InQuad } } SequentialAnimation { NumberAnimation { target: piece; property: "stretch"; to: 1.05; duration: 130 } NumberAnimation { target: piece; property: "stretch"; to: .94; duration: 170 } - NumberAnimation { target: piece; property: "stretch"; to: 1; duration: 240; easing.type: Easing.OutBack } + NumberAnimation { target: piece; property: "stretch"; to: 1; duration: piece.manner.settleTime; easing.type: piece.manner.settle } } } Model { @@ -246,7 +262,8 @@ Node { // A full lacquer mirrors the dark of the room at every grazing edge, so the sweets wear only a light glaze. clearcoatAmount: piece.woodland ? 0 : piece.design === 0 ? .2 : .35 clearcoatRoughnessAmount: piece.design === 1 ? .14 : piece.candy ? .08 : .2 - emissiveFactor: piece.sugarGlow + // A sweet warms a little in the hand. + emissiveFactor: piece.sugarGlow.times(1 + piece.held * .6) cullMode: Material.NoCulling } } @@ -291,7 +308,7 @@ Node { clearcoatAmount: piece.candy ? .35 : 0 clearcoatRoughnessAmount: piece.candy ? .08 : .2 // Orbital lights burn in their own colour whatever the room is doing. - emissiveFactor: piece.secondGlow + emissiveFactor: piece.secondGlow.times(piece.pulse) cullMode: Material.NoCulling } } diff --git a/tests/checkmate_tests.cpp b/tests/checkmate_tests.cpp index 01a2f9c..6d5fed1 100644 --- a/tests/checkmate_tests.cpp +++ b/tests/checkmate_tests.cpp @@ -819,7 +819,7 @@ private slots: auto *pawn=window->findChild("figure-20"); QVERIFY(pawn); QVERIFY(backend.move(12,28)); - QTest::qWait(100); + QTest::qWait(160); QVERIFY(pawn->property("lift").toDouble()>0); QVERIFY(pawn->property("z").toDouble()>.5); QVERIFY(pawn->property("z").toDouble()<2.5); @@ -827,15 +827,43 @@ private slots: // Quick 3D coordinates use float precision, including the final animation setter. QTRY_VERIFY_WITH_TIMEOUT(qFuzzyCompare(pawn->property("z").toFloat(),2.5f),1500); QTRY_COMPARE_WITH_TIMEOUT(pawn->property("lift").toDouble(),0.0,1500); - auto *hop=pawn->findChild("moveHop"); - QVERIFY(hop); + auto *leap=pawn->findChild("leap"); + auto *perk=pawn->findChild("perk"); + QVERIFY(leap && perk); QVERIFY(backend.move(12,28)); - QVERIFY(hop->property("running").toBool()); + QVERIFY(leap->property("running").toBool()); backend.setReducedMotion(true); - QVERIFY(!hop->property("running").toBool()); + QVERIFY(!leap->property("running").toBool()); QCOMPARE(pawn->property("lift").toDouble(),0.0); QCOMPARE(pawn->property("z").toDouble(),.5); + // Every set picks a piece up to its own height, carries it in an arc that leans into the journey, and settles it squarely. + for (int set=0;set<4;++set) { + backend.newGame(false,0); + backend.setPieceSet(set); + backend.setReducedMotion(false); + QTRY_VERIFY(board->property("clock").toDouble()>0); + backend.selectSquare(12); + QVERIFY(perk->property("running").toBool()); + const double raised=std::vector{.2,.14,.17,.17}[set]; + QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-raised)<.001); + QVERIFY(backend.move(12,28)); + QVERIFY(leap->property("running").toBool()); + QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); + QVERIFY(pawn->property("lift").toDouble()>0); + // A captured piece waits for its captor, then goes. + QVERIFY(backend.move(51,35)); + auto *taken=window->findChild("figure-"+QString::number(backend.position().board[35].id)); + QVERIFY(taken); + QVERIFY(backend.move(28,35)); + QCOMPARE(taken->property("presence").toDouble(),1.0); + QTRY_COMPARE_WITH_TIMEOUT(taken->property("presence").toDouble(),0.0,2500); + QTRY_VERIFY_WITH_TIMEOUT(!leap->property("running").toBool(),2500); + QCOMPARE(pawn->property("lean").toDouble(),0.0); + QCOMPARE(pawn->property("stretch").toDouble(),1.0); + QCOMPARE(pawn->property("lift").toDouble(),0.0); + backend.setReducedMotion(true); + } // Moss & Myth is alive: it breathes, perks up in the hand, draws its neighbours' eyes, and leaps. backend.newGame(false,0); backend.setPieceSet(2); @@ -843,16 +871,13 @@ private slots: QTRY_VERIFY(board->property("clock").toDouble()>0); QTRY_VERIFY(qAbs(pawn->property("tall").toDouble()-1)>.002); auto *neighbour=window->findChild("figure-"+QString::number(backend.position().board[11].id)); - auto *leap=pawn->findChild("leap"); - auto *perk=pawn->findChild("perk"); - QVERIFY(neighbour && leap && perk); + QVERIFY(neighbour); backend.selectSquare(12); QVERIFY(perk->property("running").toBool()); QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-.17)<.001); QTRY_VERIFY(qAbs(neighbour->property("look").toDouble())>5); QVERIFY(backend.move(12,28)); QVERIFY(leap->property("running").toBool()); - QVERIFY(!hop->property("running").toBool()); QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); QVERIFY(pawn->property("lift").toDouble()>0); QTRY_VERIFY_WITH_TIMEOUT(!leap->property("running").toBool(),2000); From 1b1387e182dc3684f382688fe590e993313d1625 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 16 Nov 2026 11:36:39 +0100 Subject: [PATCH 3/3] Settle interrupted poses and time captures to the captor A move made during the pick-up shake left the piece turned, and a pick-up during a skip could leave it floating; the journey now straightens the head and the pick-up lands the skip. A captured piece waits for the length of its captor's journey rather than a fixed 240 ms, so a long capture no longer empties the square before anyone arrives. Changing sets starts the new one from rest. Co-Authored-By: Claude Fable 5.2 --- src/ChessPiece.qml | 32 +++++++++++++++++++++++++------- tests/checkmate_tests.cpp | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/ChessPiece.qml b/src/ChessPiece.qml index 6e5f2a9..c15700a 100644 --- a/src/ChessPiece.qml +++ b/src/ChessPiece.qml @@ -12,7 +12,10 @@ Node { required property bool selected required property real seat property real lift: 0 - property real presence: record.alive ? 1 : 0 + // Followed by hand, like `place`, so a capture can be timed to its captor's arrival. + property bool alive: record.alive + property real presence: 0 + property int reprieve: 0 property bool ready: false // Moss & Myth is one carved figure per piece, painted in its mesh rather than by part. property bool woodland: design === 2 @@ -126,7 +129,7 @@ Node { Behavior on presence { id: presenceBehavior; enabled: piece.ready && piece.motion SequentialAnimation { - PauseAnimation { duration: piece.record.alive ? 0 : 240 } + PauseAnimation { duration: piece.reprieve } NumberAnimation { duration: piece.manner.fade; easing.type: piece.manner.pop && !piece.record.alive ? Easing.InBack : Easing.InCubic } } } @@ -134,14 +137,13 @@ Node { if (!motion) { xBehavior.enabled = false; zBehavior.enabled = false raiseBehavior.enabled = false; lookBehavior.enabled = false; presenceBehavior.enabled = false - leap.stop(); perk.stop(); glance.stop(); skip.stop() - lift = 0; stretch = 1; lean = 0; wiggle = 0 + compose() // Resolve moves queued before the first animation frame as well. x = Qt.binding(function() { return piece.place % 8 - 3.5 }) z = Qt.binding(function() { return 3.5 - Math.floor(piece.place / 8) }) raise = Qt.binding(function() { return piece.selected ? piece.manner.raise : 0 }) look = Qt.binding(function() { return piece.regard() }) - presence = Qt.binding(function() { return piece.record.alive ? 1 : 0 }) + presence = alive ? 1 : 0 xBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) zBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) raiseBehavior.enabled = Qt.binding(function() { return piece.ready && piece.motion }) @@ -160,14 +162,28 @@ Node { let turn = eulerRotation.y * Math.PI / 180 leanX = (dx * Math.cos(turn) - dz * Math.sin(turn)) / reach leanZ = (dx * Math.sin(turn) + dz * Math.cos(turn)) / reach - perk.stop(); skip.stop() + // The journey takes over whatever pose an interrupted stir left behind. + perk.stop(); skip.stop(); glance.stop() leap.restart() } } place = square } + onAliveChanged: { + // The captor's journey is the last move's; the taken figure starts to go just before it lands. + let from = backend.lastFrom, to = backend.lastTo + let reach = from < 0 ? 0 : Math.hypot(to % 8 - from % 8, Math.floor(to / 8) - Math.floor(from / 8)) + reprieve = alive ? 0 : Math.max(0, manner.windup + Math.min(manner.pace + 320, manner.pace + manner.pacePer * reach) - manner.fade * .4) + presence = alive ? 1 : 0 + } onSelectedChanged: if (selected && motion && ready) { skip.stop(); glance.stop(); perk.restart() } - Component.onCompleted: { place = square; ready = true } + // A new set starts from rest rather than finishing the last one's gesture. + onDesignChanged: compose() + Component.onCompleted: { place = square; presence = alive ? 1 : 0; ready = true } + function compose() { + leap.stop(); perk.stop(); glance.stop(); skip.stop() + lift = 0; stretch = 1; lean = 0; wiggle = 0 + } // Now and then the board asks an idle figure to stir: a look to one side, or a small skip from the sweets, the young and the foxes. function fidget() { if (!motion || !record.alive || liveliness < 1 || selected || look !== 0) return @@ -194,6 +210,7 @@ Node { NumberAnimation { target: piece; property: "lean"; to: piece.manner.lean; duration: piece.travel * .35; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "lean"; to: piece.manner.counter; duration: piece.travel * .65; easing.type: Easing.InOutQuad } } + NumberAnimation { target: piece; property: "wiggle"; to: 0; duration: piece.travel * .5; easing.type: Easing.OutQuad } } ParallelAnimation { SequentialAnimation { @@ -212,6 +229,7 @@ Node { ParallelAnimation { id: perk objectName: "perk" + NumberAnimation { target: piece; property: "lift"; to: 0; duration: 150; easing.type: Easing.OutQuad } SequentialAnimation { NumberAnimation { target: piece; property: "stretch"; to: piece.manner.start; duration: 70; easing.type: Easing.OutQuad } NumberAnimation { target: piece; property: "stretch"; to: piece.manner.reach; duration: 150; easing.type: Easing.OutQuad } diff --git a/tests/checkmate_tests.cpp b/tests/checkmate_tests.cpp index 6d5fed1..a7f04ca 100644 --- a/tests/checkmate_tests.cpp +++ b/tests/checkmate_tests.cpp @@ -847,6 +847,13 @@ private slots: QVERIFY(perk->property("running").toBool()); const double raised=std::vector{.2,.14,.17,.17}[set]; QTRY_VERIFY(qAbs(pawn->property("raise").toDouble()-raised)<.001); + // A move made mid-shake, or a pick-up mid-skip, leaves nothing of the interrupted pose behind. + pawn->setProperty("wiggle",8.0); + pawn->setProperty("lift",.05); + backend.selectSquare(12); + backend.selectSquare(12); + QTRY_COMPARE(pawn->property("lift").toDouble(),0.0); + pawn->setProperty("wiggle",8.0); QVERIFY(backend.move(12,28)); QVERIFY(leap->property("running").toBool()); QTRY_VERIFY(qAbs(pawn->property("lean").toDouble())>2); @@ -862,7 +869,22 @@ private slots: QCOMPARE(pawn->property("lean").toDouble(),0.0); QCOMPARE(pawn->property("stretch").toDouble(),1.0); QCOMPARE(pawn->property("lift").toDouble(),0.0); + QCOMPARE(pawn->property("wiggle").toDouble(),0.0); + // A long capture is waited out: the taken piece is still whole when a short one would already have gone. + QVERIFY(backend.move(59,35)); + auto *queen=window->findChild("figure-"+QString::number(backend.position().board[35].id)); + auto *far=window->findChild("figure-"+QString::number(backend.position().board[7].id)); + QVERIFY(queen && far); + QVERIFY(backend.move(14,22)); + QVERIFY(backend.move(35,7)); + QVERIFY(far->property("reprieve").toInt()>taken->property("reprieve").toInt()+150); + QCOMPARE(far->property("presence").toDouble(),1.0); + // Changing sets mid-journey starts the new one from rest. + backend.setPieceSet((set+1)%4); + QVERIFY(!queen->findChild("leap")->property("running").toBool()); + QCOMPARE(queen->property("lean").toDouble(),0.0); backend.setReducedMotion(true); + QCOMPARE(far->property("presence").toDouble(),0.0); } // Moss & Myth is alive: it breathes, perks up in the hand, draws its neighbours' eyes, and leaps. backend.newGame(false,0);