BlueGit

projects-timfalken-com meteors

feat: halve only the cluster post-apex float-down (t1124)

Tim's 'daalsnelheid' referred only to how flying clusters float back
down after a jump, including the apex ease (scaled with the halved
terminal speed). Restore spawn fall, unsupported/released singles and
dropped cargo to the original fallSpeed. Manual jumps also descend at
full speed. Cargo that is part of a descending cluster still rides
with it. Planet ratios and upward launch are unchanged.

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
1cd12c88fc87ac9134a4f1374e7443b6682f635d
Parent
90b65716
8 files changed +151 −39
src/gameCore.js +22 −6
@@ -730,10 +730,25 @@ GameCore.prototype.clusterMembers = function (clusterId)
730 730 * Advance a jump (cluster or manual) by dt. Uses exact kinematics so a
731 731 * jump of height H peaks at exactly H after riseTime. Returns dy.
732 732 * Mutates body.vy and body.phase ('up' / 'down'). body.decel is the
733 * upward deceleration. After the apex, vy eases from 0 to -fallSpeed
734 * at planet.fallAccel, then stays at terminal fallSpeed.
733 * upward deceleration. After the apex, vy eases from 0 to the
734 * terminal descent speed at the matching accel, then stays there.
735 * Flying clusters (forCluster) use the halved cluster float-down
736 * (t1122 / t1124); manual jumps use the full single-block fallSpeed.
735 737 */
736 GameCore.prototype.advanceJump = function (body, dt)
738 GameCore.prototype.descentParams = function (forCluster)
739 {
740 var p = this.planet;
741 if (forCluster)
742 {
743 return {
744 fallSpeed: p.clusterFallSpeed,
745 fallAccel: p.clusterFallAccel
746 };
747 }
748 return { fallSpeed: p.fallSpeed, fallAccel: p.fallAccel };
749 };
750
751 GameCore.prototype.advanceJump = function (body, dt, forCluster)
737 752 {
738 753 var dy = 0;
739 754 var left = dt;
@@ -764,8 +779,9 @@ GameCore.prototype.advanceJump = function (body, dt)
764 779 }
765 780 if (body.phase === 'down' && left > 0)
766 781 {
767 var target = -this.planet.fallSpeed;
768 var accel = this.planet.fallAccel;
782 var desc = this.descentParams(forCluster);
783 var target = -desc.fallSpeed;
784 var accel = desc.fallAccel;
769 785 if (accel < 1e-12)
770 786 {
771 787 body.vy = target;
@@ -815,7 +831,7 @@ GameCore.prototype.integrateClusters = function (dt)
815 831 { continue; }
816 832
817 833 this.prepareClusterBody(cluster);
818 var dy = this.advanceJump(cluster, dt);
834 var dy = this.advanceJump(cluster, dt, true);
819 835 cluster.anchorY += dy;
820 836 this.syncClusterMembers(cluster);
821 837
@@ -730,10 +730,25 @@ GameCore.prototype.clusterMembers = function (clusterId)
730 * Advance a jump (cluster or manual) by dt. Uses exact kinematics so a
730 * Advance a jump (cluster or manual) by dt. Uses exact kinematics so a
731 * jump of height H peaks at exactly H after riseTime. Returns dy.
731 * jump of height H peaks at exactly H after riseTime. Returns dy.
732 * Mutates body.vy and body.phase ('up' / 'down'). body.decel is the
732 * Mutates body.vy and body.phase ('up' / 'down'). body.decel is the
733 * upward deceleration. After the apex, vy eases from 0 to -fallSpeed
733 * upward deceleration. After the apex, vy eases from 0 to the
734 * at planet.fallAccel, then stays at terminal fallSpeed.
734 * terminal descent speed at the matching accel, then stays there.
735 * Flying clusters (forCluster) use the halved cluster float-down
736 * (t1122 / t1124); manual jumps use the full single-block fallSpeed.
735 */
737 */
736GameCore.prototype.advanceJump = function (body, dt)
738GameCore.prototype.descentParams = function (forCluster)
739{
740 var p = this.planet;
741 if (forCluster)
742 {
743 return {
744 fallSpeed: p.clusterFallSpeed,
745 fallAccel: p.clusterFallAccel
746 };
747 }
748 return { fallSpeed: p.fallSpeed, fallAccel: p.fallAccel };
749};
750
751GameCore.prototype.advanceJump = function (body, dt, forCluster)
737{
752{
738 var dy = 0;
753 var dy = 0;
739 var left = dt;
754 var left = dt;
@@ -764,8 +779,9 @@ GameCore.prototype.advanceJump = function (body, dt)
764 }
779 }
765 if (body.phase === 'down' && left > 0)
780 if (body.phase === 'down' && left > 0)
766 {
781 {
767 var target = -this.planet.fallSpeed;
782 var desc = this.descentParams(forCluster);
768 var accel = this.planet.fallAccel;
783 var target = -desc.fallSpeed;
784 var accel = desc.fallAccel;
769 if (accel < 1e-12)
785 if (accel < 1e-12)
770 {
786 {
771 body.vy = target;
787 body.vy = target;
@@ -815,7 +831,7 @@ GameCore.prototype.integrateClusters = function (dt)
815 { continue; }
831 { continue; }
816
832
817 this.prepareClusterBody(cluster);
833 this.prepareClusterBody(cluster);
818 var dy = this.advanceJump(cluster, dt);
834 var dy = this.advanceJump(cluster, dt, true);
819 cluster.anchorY += dy;
835 cluster.anchorY += dy;
820 this.syncClusterMembers(cluster);
836 this.syncClusterMembers(cluster);
821
837
src/planet.js +18 −13
@@ -14,10 +14,11 @@
14 14 * one jump from the floor clears the 13-tile field with room to spare;
15 15 * at 4 you still need more than one jump, but each is 50% taller.
16 16 * Air (fallTime): 1 s (hard, fast fall) .. 5 s (easy, slow fall).
17 * After a jump peaks, blocks float down at DESCENT_SPEED_SCALE *
18 * FIELD_HEIGHT / fallTime tiles/s (DESCENT_SPEED_SCALE is 0.5 since
19 * t1122: all descent speeds are halved). Relative differences between
20 * planets (1 / fallTime) are unchanged. Upward launch is not affected.
17 * Spawn, unsupported and cargo blocks fall at FIELD_HEIGHT / fallTime
18 * tiles/s. After a jump peaks, a flying cluster floats down at
19 * DESCENT_SPEED_SCALE * that speed (0.5 since t1122 / t1124: only the
20 * cluster float-down is halved). Relative differences between planets
21 * (1 / fallTime) are unchanged. Upward launch is not affected.
21 22 * Mass (riseTime): 0.5 s (hard, fast jump) .. 3 s (easy, slow jump).
22 23 * Time to reach the apex, independent of jump height.
23 24 *
@@ -35,9 +36,10 @@ var FIELD_HEIGHT = 13;
35 36 /** t1119: every match jump (the gravity-applied minimum and the
36 37 * vertical / extra-block bonuses derived from it) is 50% higher. */
37 38 var JUMP_HEIGHT_SCALE = 1.5;
38 /** t1122: every descent speed is halved. Terminal fallSpeed, spawn
39 * fall, unsupported / released / cargo fall, and the post-apex
40 * float-down all use this scale. Upward launch is unchanged. */
39 /** t1122 / t1124: only a flying cluster's post-apex float-down
40 * (terminal speed and the apex ease into it) is halved. Spawn fall,
41 * unsupported / released singles and dropped cargo use the full
42 * fallSpeed. Upward launch is unchanged. */
41 43 var DESCENT_SPEED_SCALE = 0.5;
42 44
43 45
@@ -73,13 +75,16 @@ function createPlanet (opts)
73 75 riseTime: riseTime,
74 76 colors: colors,
75 77 baseJumpHeight: JUMP_HEIGHT_SCALE * FIELD_HEIGHT / jumpsToClear,
76 fallSpeed: DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime,
77 // Time to ease from vy=0 at the apex to terminal fallSpeed.
78 // Shorter when air resistance is low (small fallTime). The ease
79 // duration is unchanged; fallAccel scales with the halved
80 // fallSpeed so the ease still lasts apexEaseTime seconds.
78 // Single-block fall (spawn, unsupported, dropped cargo).
79 fallSpeed: FIELD_HEIGHT / fallTime,
80 // Time to ease from vy=0 at the apex to terminal speed.
81 // Shorter when air resistance is low (small fallTime).
81 82 apexEaseTime: 0.15 * fallTime,
82 fallAccel: (DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
83 fallAccel: (FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
84 // t1122 / t1124: flying-cluster float-down only. Same ease
85 // duration; accel scales with the halved terminal speed.
86 clusterFallSpeed: DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime,
87 clusterFallAccel: (DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
83 88 // Visual landing bounce: faster at low air resistance. Stage-3 params.
84 89 bounceDuration: 0.12 * fallTime,
85 90 bounceSquash: 0.16
@@ -14,10 +14,11 @@
14 * one jump from the floor clears the 13-tile field with room to spare;
14 * one jump from the floor clears the 13-tile field with room to spare;
15 * at 4 you still need more than one jump, but each is 50% taller.
15 * at 4 you still need more than one jump, but each is 50% taller.
16 * Air (fallTime): 1 s (hard, fast fall) .. 5 s (easy, slow fall).
16 * Air (fallTime): 1 s (hard, fast fall) .. 5 s (easy, slow fall).
17 * After a jump peaks, blocks float down at DESCENT_SPEED_SCALE *
17 * Spawn, unsupported and cargo blocks fall at FIELD_HEIGHT / fallTime
18 * FIELD_HEIGHT / fallTime tiles/s (DESCENT_SPEED_SCALE is 0.5 since
18 * tiles/s. After a jump peaks, a flying cluster floats down at
19 * t1122: all descent speeds are halved). Relative differences between
19 * DESCENT_SPEED_SCALE * that speed (0.5 since t1122 / t1124: only the
20 * planets (1 / fallTime) are unchanged. Upward launch is not affected.
20 * cluster float-down is halved). Relative differences between planets
21 * (1 / fallTime) are unchanged. Upward launch is not affected.
21 * Mass (riseTime): 0.5 s (hard, fast jump) .. 3 s (easy, slow jump).
22 * Mass (riseTime): 0.5 s (hard, fast jump) .. 3 s (easy, slow jump).
22 * Time to reach the apex, independent of jump height.
23 * Time to reach the apex, independent of jump height.
23 *
24 *
@@ -35,9 +36,10 @@ var FIELD_HEIGHT = 13;
35/** t1119: every match jump (the gravity-applied minimum and the
36/** t1119: every match jump (the gravity-applied minimum and the
36 * vertical / extra-block bonuses derived from it) is 50% higher. */
37 * vertical / extra-block bonuses derived from it) is 50% higher. */
37var JUMP_HEIGHT_SCALE = 1.5;
38var JUMP_HEIGHT_SCALE = 1.5;
38/** t1122: every descent speed is halved. Terminal fallSpeed, spawn
39/** t1122 / t1124: only a flying cluster's post-apex float-down
39 * fall, unsupported / released / cargo fall, and the post-apex
40 * (terminal speed and the apex ease into it) is halved. Spawn fall,
40 * float-down all use this scale. Upward launch is unchanged. */
41 * unsupported / released singles and dropped cargo use the full
42 * fallSpeed. Upward launch is unchanged. */
41var DESCENT_SPEED_SCALE = 0.5;
43var DESCENT_SPEED_SCALE = 0.5;
42
44
43
45
@@ -73,13 +75,16 @@ function createPlanet (opts)
73 riseTime: riseTime,
75 riseTime: riseTime,
74 colors: colors,
76 colors: colors,
75 baseJumpHeight: JUMP_HEIGHT_SCALE * FIELD_HEIGHT / jumpsToClear,
77 baseJumpHeight: JUMP_HEIGHT_SCALE * FIELD_HEIGHT / jumpsToClear,
76 fallSpeed: DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime,
78 // Single-block fall (spawn, unsupported, dropped cargo).
77 // Time to ease from vy=0 at the apex to terminal fallSpeed.
79 fallSpeed: FIELD_HEIGHT / fallTime,
78 // Shorter when air resistance is low (small fallTime). The ease
80 // Time to ease from vy=0 at the apex to terminal speed.
79 // duration is unchanged; fallAccel scales with the halved
81 // Shorter when air resistance is low (small fallTime).
80 // fallSpeed so the ease still lasts apexEaseTime seconds.
81 apexEaseTime: 0.15 * fallTime,
82 apexEaseTime: 0.15 * fallTime,
82 fallAccel: (DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
83 fallAccel: (FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
84 // t1122 / t1124: flying-cluster float-down only. Same ease
85 // duration; accel scales with the halved terminal speed.
86 clusterFallSpeed: DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime,
87 clusterFallAccel: (DESCENT_SPEED_SCALE * FIELD_HEIGHT / fallTime) / (0.15 * fallTime),
83 // Visual landing bounce: faster at low air resistance. Stage-3 params.
88 // Visual landing bounce: faster at low air resistance. Stage-3 params.
84 bounceDuration: 0.12 * fallTime,
89 bounceDuration: 0.12 * fallTime,
85 bounceSquash: 0.16
90 bounceSquash: 0.16
test/cluster-descent.test.js added +79 −0
@@ -0,0 +1,79 @@
1 'use strict';
2
3 const { describe, it } = require('node:test');
4 const assert = require('node:assert/strict');
5 const { makeGame, placeRow, almost, Planet } = require('./helpers.js');
6
7 describe('Cluster float-down is halved, single-block fall is not (t1124)', () =>
8 {
9 it('a newly spawned block falls at the full fallSpeed', () =>
10 {
11 const g = makeGame({ seed: 3 });
12 const spawned = g.trySpawn();
13 assert.ok(spawned);
14 assert.equal(spawned.state, 'falling');
15 assert.ok(almost(spawned.vy, -g.planet.fallSpeed, 1e-12));
16 assert.ok(g.planet.fallSpeed > g.planet.clusterFallSpeed + 0.5);
17 const y1 = spawned.y;
18 g.step(0.2, 1 / 120);
19 const speed = (y1 - spawned.y) / 0.2;
20 assert.ok(almost(speed, g.planet.fallSpeed, 0.15), 'spawn speed=' + speed);
21 });
22
23 it('unsupported and ingested garbage fall at the full fallSpeed', () =>
24 {
25 const g = makeGame({ noSpawn: true, seed: 2 });
26 const hanging = g.place(0, 4, 1);
27 g.releaseUnsupported();
28 assert.equal(hanging.state, 'falling');
29 assert.ok(almost(hanging.vy, 0, 1e-12), 'starts from rest');
30 g.step(g.planet.apexEaseTime + 0.05, 1 / 120);
31 assert.ok(almost(Math.abs(hanging.vy), g.planet.fallSpeed, 0.1),
32 'unsupported terminal vy=' + hanging.vy);
33
34 const garbage = g.ingestGarbage(3);
35 assert.ok(almost(garbage.vy, -g.planet.fallSpeed, 1e-12));
36 });
37
38 it('a launched cluster eases into the halved clusterFallSpeed, not fallSpeed', () =>
39 {
40 const g = makeGame({ noSpawn: true });
41 placeRow(g, 0, [0, 1, 2], 0);
42 g.resolveMatches();
43 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
44 const cluster = g.clusters[g.blocks[0].clusterId];
45 assert.ok(cluster, 'still flying');
46 assert.equal(cluster.phase, 'down');
47 assert.ok(almost(Math.abs(cluster.vy), g.planet.clusterFallSpeed, 0.08),
48 'cluster vy=' + cluster.vy + ' expected ' + (-g.planet.clusterFallSpeed));
49 assert.ok(Math.abs(cluster.vy) < g.planet.fallSpeed - 0.5,
50 'must not use the full single-block fallSpeed');
51 });
52
53 it('a manual jump comes down at the full fallSpeed', () =>
54 {
55 const g = makeGame({ noSpawn: true });
56 const block = g.place(4, 0, 2);
57 g.startManualLaunch(block);
58 assert.equal(block.state, 'manual');
59 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
60 assert.equal(block.manualPhase, 'down');
61 assert.ok(almost(Math.abs(block.vy), g.planet.fallSpeed, 0.12),
62 'manual vy=' + block.vy + ' expected ' + (-g.planet.fallSpeed));
63 assert.ok(Math.abs(block.vy) > g.planet.clusterFallSpeed + 0.5);
64 });
65
66 it('cargo riding a descending cluster shares the halved float-down', () =>
67 {
68 const g = makeGame({ noSpawn: true });
69 placeRow(g, 0, [0, 1, 2], 0);
70 const cargo = g.place(1, 1, 4);
71 g.resolveMatches();
72 assert.equal(cargo.state, 'flying');
73 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
74 const cluster = g.clusters[cargo.clusterId];
75 assert.ok(cluster);
76 assert.ok(almost(Math.abs(cluster.vy), g.planet.clusterFallSpeed, 0.08));
77 assert.ok(almost(cargo.vy, cluster.vy, 1e-9));
78 });
79 });
@@ -0,0 +1,79 @@
1'use strict';
2
3const { describe, it } = require('node:test');
4const assert = require('node:assert/strict');
5const { makeGame, placeRow, almost, Planet } = require('./helpers.js');
6
7describe('Cluster float-down is halved, single-block fall is not (t1124)', () =>
8{
9 it('a newly spawned block falls at the full fallSpeed', () =>
10 {
11 const g = makeGame({ seed: 3 });
12 const spawned = g.trySpawn();
13 assert.ok(spawned);
14 assert.equal(spawned.state, 'falling');
15 assert.ok(almost(spawned.vy, -g.planet.fallSpeed, 1e-12));
16 assert.ok(g.planet.fallSpeed > g.planet.clusterFallSpeed + 0.5);
17 const y1 = spawned.y;
18 g.step(0.2, 1 / 120);
19 const speed = (y1 - spawned.y) / 0.2;
20 assert.ok(almost(speed, g.planet.fallSpeed, 0.15), 'spawn speed=' + speed);
21 });
22
23 it('unsupported and ingested garbage fall at the full fallSpeed', () =>
24 {
25 const g = makeGame({ noSpawn: true, seed: 2 });
26 const hanging = g.place(0, 4, 1);
27 g.releaseUnsupported();
28 assert.equal(hanging.state, 'falling');
29 assert.ok(almost(hanging.vy, 0, 1e-12), 'starts from rest');
30 g.step(g.planet.apexEaseTime + 0.05, 1 / 120);
31 assert.ok(almost(Math.abs(hanging.vy), g.planet.fallSpeed, 0.1),
32 'unsupported terminal vy=' + hanging.vy);
33
34 const garbage = g.ingestGarbage(3);
35 assert.ok(almost(garbage.vy, -g.planet.fallSpeed, 1e-12));
36 });
37
38 it('a launched cluster eases into the halved clusterFallSpeed, not fallSpeed', () =>
39 {
40 const g = makeGame({ noSpawn: true });
41 placeRow(g, 0, [0, 1, 2], 0);
42 g.resolveMatches();
43 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
44 const cluster = g.clusters[g.blocks[0].clusterId];
45 assert.ok(cluster, 'still flying');
46 assert.equal(cluster.phase, 'down');
47 assert.ok(almost(Math.abs(cluster.vy), g.planet.clusterFallSpeed, 0.08),
48 'cluster vy=' + cluster.vy + ' expected ' + (-g.planet.clusterFallSpeed));
49 assert.ok(Math.abs(cluster.vy) < g.planet.fallSpeed - 0.5,
50 'must not use the full single-block fallSpeed');
51 });
52
53 it('a manual jump comes down at the full fallSpeed', () =>
54 {
55 const g = makeGame({ noSpawn: true });
56 const block = g.place(4, 0, 2);
57 g.startManualLaunch(block);
58 assert.equal(block.state, 'manual');
59 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
60 assert.equal(block.manualPhase, 'down');
61 assert.ok(almost(Math.abs(block.vy), g.planet.fallSpeed, 0.12),
62 'manual vy=' + block.vy + ' expected ' + (-g.planet.fallSpeed));
63 assert.ok(Math.abs(block.vy) > g.planet.clusterFallSpeed + 0.5);
64 });
65
66 it('cargo riding a descending cluster shares the halved float-down', () =>
67 {
68 const g = makeGame({ noSpawn: true });
69 placeRow(g, 0, [0, 1, 2], 0);
70 const cargo = g.place(1, 1, 4);
71 g.resolveMatches();
72 assert.equal(cargo.state, 'flying');
73 g.step(g.planet.riseTime + g.planet.apexEaseTime + 0.05, 1 / 240);
74 const cluster = g.clusters[cargo.clusterId];
75 assert.ok(cluster);
76 assert.ok(almost(Math.abs(cluster.vy), g.planet.clusterFallSpeed, 0.08));
77 assert.ok(almost(cargo.vy, cluster.vy, 1e-9));
78 });
79});
test/falling-cluster.test.js +9 −9
@@ -38,9 +38,9 @@ describe('Falling blocks land on flying clusters', () =>
38 38 cluster.vy = 0;
39 39 const falling = g.createBlock(3, 10, 1, 'falling');
40 40 falling.vy = -g.planet.fallSpeed;
41 // Fall from 10 onto 6+1=7: distance 3, at halved fallSpeed
42 // 0.5 * 13/3 ≈ 2.17 → ~1.4s (t1122).
43 g.step(2.0, 1 / 120);
41 // Fall from 10 onto 6+1=7: distance 3, at full spawn fallSpeed
42 // 13/3 ≈ 4.33 → ~0.7s (t1124: singles are not halved).
43 g.step(1.0, 1 / 120);
44 44 assert.equal(falling.state, 'flying', 'should have attached, state=' + falling.state + ' y=' + falling.y);
45 45 assert.equal(falling.clusterId, cluster.id);
46 46 assert.equal(falling.flame, false, 'cargo has no flame');
@@ -49,7 +49,7 @@ describe('Falling blocks land on flying clusters', () =>
49 49
50 50 // Now let the cluster descend: cargo must move with it, same dy.
51 51 cluster.phase = 'down';
52 cluster.vy = 0; // will ease into fallSpeed
52 cluster.vy = 0; // will ease into clusterFallSpeed
53 53 const yCargo = falling.y;
54 54 const yFlyer = members[1].y;
55 55 g.step(0.4, 1 / 120);
@@ -69,10 +69,10 @@ describe('Falling blocks land on flying clusters', () =>
69 69 cluster.vy = -g.planet.fallSpeed;
70 70 const falling = g.createBlock(1, 8, 2, 'falling');
71 71 falling.vy = -g.planet.fallSpeed;
72 // Same terminal speed as the cluster, so they only meet after
73 // the cluster lands. With halved descent (t1122) that takes
74 // roughly 2× as long as before (~3.7 s).
75 g.step(5.0, 1 / 120);
72 // The falling single is at full fallSpeed; the cluster floats
73 // at the halved clusterFallSpeed (t1124), so the single catches
74 // up. 2 s is plenty for a 3-tile gap.
75 g.step(2.0, 1 / 120);
76 76 assert.notEqual(falling.state, 'falling');
77 77 assert.ok(falling.state === 'flying' || falling.state === 'settling' || falling.state === 'still',
78 78 'must not still be falling through, state=' + falling.state + ' y=' + falling.y);
@@ -174,7 +174,7 @@ describe('Rigid grey landing', () =>
174 174 assert.ok(right.state === 'falling' || (right.state === 'still' && almost(right.y, 0, 0.05)),
175 175 'right falls, state=' + right.state);
176 176 // Give them time to land individually.
177 g.step(g.planet.fallTime / Planet.DESCENT_SPEED_SCALE + 0.5, 1 / 60);
177 g.step(g.planet.fallTime + 0.5, 1 / 60);
178 178 assert.equal(left.state, 'still');
179 179 assert.ok(almost(left.y, 0, 0.05), 'left lands on the floor, y=' + left.y);
180 180 assert.equal(right.state, 'still');
@@ -38,9 +38,9 @@ describe('Falling blocks land on flying clusters', () =>
38 cluster.vy = 0;
38 cluster.vy = 0;
39 const falling = g.createBlock(3, 10, 1, 'falling');
39 const falling = g.createBlock(3, 10, 1, 'falling');
40 falling.vy = -g.planet.fallSpeed;
40 falling.vy = -g.planet.fallSpeed;
41 // Fall from 10 onto 6+1=7: distance 3, at halved fallSpeed
41 // Fall from 10 onto 6+1=7: distance 3, at full spawn fallSpeed
42 // 0.5 * 13/3 ≈ 2.17 → ~1.4s (t1122).
42 // 13/3 ≈ 4.33 → ~0.7s (t1124: singles are not halved).
43 g.step(2.0, 1 / 120);
43 g.step(1.0, 1 / 120);
44 assert.equal(falling.state, 'flying', 'should have attached, state=' + falling.state + ' y=' + falling.y);
44 assert.equal(falling.state, 'flying', 'should have attached, state=' + falling.state + ' y=' + falling.y);
45 assert.equal(falling.clusterId, cluster.id);
45 assert.equal(falling.clusterId, cluster.id);
46 assert.equal(falling.flame, false, 'cargo has no flame');
46 assert.equal(falling.flame, false, 'cargo has no flame');
@@ -49,7 +49,7 @@ describe('Falling blocks land on flying clusters', () =>
49
49
50 // Now let the cluster descend: cargo must move with it, same dy.
50 // Now let the cluster descend: cargo must move with it, same dy.
51 cluster.phase = 'down';
51 cluster.phase = 'down';
52 cluster.vy = 0; // will ease into fallSpeed
52 cluster.vy = 0; // will ease into clusterFallSpeed
53 const yCargo = falling.y;
53 const yCargo = falling.y;
54 const yFlyer = members[1].y;
54 const yFlyer = members[1].y;
55 g.step(0.4, 1 / 120);
55 g.step(0.4, 1 / 120);
@@ -69,10 +69,10 @@ describe('Falling blocks land on flying clusters', () =>
69 cluster.vy = -g.planet.fallSpeed;
69 cluster.vy = -g.planet.fallSpeed;
70 const falling = g.createBlock(1, 8, 2, 'falling');
70 const falling = g.createBlock(1, 8, 2, 'falling');
71 falling.vy = -g.planet.fallSpeed;
71 falling.vy = -g.planet.fallSpeed;
72 // Same terminal speed as the cluster, so they only meet after
72 // The falling single is at full fallSpeed; the cluster floats
73 // the cluster lands. With halved descent (t1122) that takes
73 // at the halved clusterFallSpeed (t1124), so the single catches
74 // roughly 2× as long as before (~3.7 s).
74 // up. 2 s is plenty for a 3-tile gap.
75 g.step(5.0, 1 / 120);
75 g.step(2.0, 1 / 120);
76 assert.notEqual(falling.state, 'falling');
76 assert.notEqual(falling.state, 'falling');
77 assert.ok(falling.state === 'flying' || falling.state === 'settling' || falling.state === 'still',
77 assert.ok(falling.state === 'flying' || falling.state === 'settling' || falling.state === 'still',
78 'must not still be falling through, state=' + falling.state + ' y=' + falling.y);
78 'must not still be falling through, state=' + falling.state + ' y=' + falling.y);
@@ -174,7 +174,7 @@ describe('Rigid grey landing', () =>
174 assert.ok(right.state === 'falling' || (right.state === 'still' && almost(right.y, 0, 0.05)),
174 assert.ok(right.state === 'falling' || (right.state === 'still' && almost(right.y, 0, 0.05)),
175 'right falls, state=' + right.state);
175 'right falls, state=' + right.state);
176 // Give them time to land individually.
176 // Give them time to land individually.
177 g.step(g.planet.fallTime / Planet.DESCENT_SPEED_SCALE + 0.5, 1 / 60);
177 g.step(g.planet.fallTime + 0.5, 1 / 60);
178 assert.equal(left.state, 'still');
178 assert.equal(left.state, 'still');
179 assert.ok(almost(left.y, 0, 0.05), 'left lands on the floor, y=' + left.y);
179 assert.ok(almost(left.y, 0, 0.05), 'left lands on the floor, y=' + left.y);
180 assert.equal(right.state, 'still');
180 assert.equal(right.state, 'still');
test/match.test.js +7 −5
@@ -159,21 +159,23 @@ describe('Launch physics', () =>
159 159 assert.ok(Math.abs(apex - (startY + H)) < 0.08, 'apex y=' + apex + ' expected ' + (startY + H));
160 160 const cluster = g.clusters[g.blocks[0].clusterId];
161 161 assert.equal(cluster.phase, 'down');
162 // Just after the apex, speed is still below terminal fallSpeed.
162 // Just after the apex, speed is still below the (halved) cluster float-down.
163 163 const ease = g.planet.apexEaseTime;
164 const clusterFall = g.planet.clusterFallSpeed;
164 165 assert.ok(ease > 0.1, 'apexEaseTime=' + ease);
165 166 g.step(ease * 0.4, 1 / 240);
166 167 const midVy = Math.abs(g.blocks[0].vy);
167 168 assert.ok(midVy > 0.2, 'should have started descending, vy=' + g.blocks[0].vy);
168 assert.ok(midVy < g.planet.fallSpeed - 0.3, 'should still be easing, vy=' + g.blocks[0].vy + ' fall=' + g.planet.fallSpeed);
169 // After the ease, descent is at constant fallSpeed.
169 assert.ok(midVy < clusterFall - 0.15, 'should still be easing, vy=' + g.blocks[0].vy + ' clusterFall=' + clusterFall);
170 // After the ease, descent is at constant clusterFallSpeed (t1124).
170 171 g.step(ease * 0.6 + 0.05, 1 / 240);
171 assert.ok(Math.abs(Math.abs(g.blocks[0].vy) - g.planet.fallSpeed) < 0.08, 'terminal vy=' + g.blocks[0].vy);
172 assert.ok(Math.abs(Math.abs(g.blocks[0].vy) - clusterFall) < 0.08, 'terminal vy=' + g.blocks[0].vy);
173 assert.ok(clusterFall < g.planet.fallSpeed - 0.5, 'cluster float-down is slower than spawn fall');
172 174 const y1 = g.blocks[0].y;
173 175 g.step(0.2, 1 / 120);
174 176 const y2 = g.blocks[0].y;
175 177 const speed = (y1 - y2) / 0.2;
176 assert.ok(Math.abs(speed - g.planet.fallSpeed) < 0.15, 'fall speed ' + speed);
178 assert.ok(Math.abs(speed - clusterFall) < 0.15, 'fall speed ' + speed);
177 179 assert.ok(y2 < y1, 'must be going down');
178 180 });
179 181 });
@@ -159,21 +159,23 @@ describe('Launch physics', () =>
159 assert.ok(Math.abs(apex - (startY + H)) < 0.08, 'apex y=' + apex + ' expected ' + (startY + H));
159 assert.ok(Math.abs(apex - (startY + H)) < 0.08, 'apex y=' + apex + ' expected ' + (startY + H));
160 const cluster = g.clusters[g.blocks[0].clusterId];
160 const cluster = g.clusters[g.blocks[0].clusterId];
161 assert.equal(cluster.phase, 'down');
161 assert.equal(cluster.phase, 'down');
162 // Just after the apex, speed is still below terminal fallSpeed.
162 // Just after the apex, speed is still below the (halved) cluster float-down.
163 const ease = g.planet.apexEaseTime;
163 const ease = g.planet.apexEaseTime;
164 const clusterFall = g.planet.clusterFallSpeed;
164 assert.ok(ease > 0.1, 'apexEaseTime=' + ease);
165 assert.ok(ease > 0.1, 'apexEaseTime=' + ease);
165 g.step(ease * 0.4, 1 / 240);
166 g.step(ease * 0.4, 1 / 240);
166 const midVy = Math.abs(g.blocks[0].vy);
167 const midVy = Math.abs(g.blocks[0].vy);
167 assert.ok(midVy > 0.2, 'should have started descending, vy=' + g.blocks[0].vy);
168 assert.ok(midVy > 0.2, 'should have started descending, vy=' + g.blocks[0].vy);
168 assert.ok(midVy < g.planet.fallSpeed - 0.3, 'should still be easing, vy=' + g.blocks[0].vy + ' fall=' + g.planet.fallSpeed);
169 assert.ok(midVy < clusterFall - 0.15, 'should still be easing, vy=' + g.blocks[0].vy + ' clusterFall=' + clusterFall);
169 // After the ease, descent is at constant fallSpeed.
170 // After the ease, descent is at constant clusterFallSpeed (t1124).
170 g.step(ease * 0.6 + 0.05, 1 / 240);
171 g.step(ease * 0.6 + 0.05, 1 / 240);
171 assert.ok(Math.abs(Math.abs(g.blocks[0].vy) - g.planet.fallSpeed) < 0.08, 'terminal vy=' + g.blocks[0].vy);
172 assert.ok(Math.abs(Math.abs(g.blocks[0].vy) - clusterFall) < 0.08, 'terminal vy=' + g.blocks[0].vy);
173 assert.ok(clusterFall < g.planet.fallSpeed - 0.5, 'cluster float-down is slower than spawn fall');
172 const y1 = g.blocks[0].y;
174 const y1 = g.blocks[0].y;
173 g.step(0.2, 1 / 120);
175 g.step(0.2, 1 / 120);
174 const y2 = g.blocks[0].y;
176 const y2 = g.blocks[0].y;
175 const speed = (y1 - y2) / 0.2;
177 const speed = (y1 - y2) / 0.2;
176 assert.ok(Math.abs(speed - g.planet.fallSpeed) < 0.15, 'fall speed ' + speed);
178 assert.ok(Math.abs(speed - clusterFall) < 0.15, 'fall speed ' + speed);
177 assert.ok(y2 < y1, 'must be going down');
179 assert.ok(y2 < y1, 'must be going down');
178 });
180 });
179});
181});
test/offline-playwright.py +3 −1
@@ -83,6 +83,7 @@ def run(page, tag):
83 83 schedule: app.battle && app.battle.schedule,
84 84 jump: app.planet && app.planet.baseJumpHeight,
85 85 fall: app.planet && app.planet.fallSpeed,
86 clusterFall: app.planet && app.planet.clusterFallSpeed,
86 87 })""")
87 88 print("HUD", hud)
88 89 check(hud["hidden"] is False, f"{tag}: offline HUD visible")
@@ -91,7 +92,8 @@ def run(page, tag):
91 92 check(hud["skill"] == "Skill 5%", f"{tag}: skill 5% ({hud['skill']})")
92 93 check(hud["bots"] == 1, f"{tag}: one bot field")
93 94 check(abs(hud["jump"] - 1.5 * 13 / 2) < 1e-9, f"{tag}: +50% jump height ({hud['jump']})")
94 check(abs(hud["fall"] - 0.5 * 13 / 3) < 1e-9, f"{tag}: halved fallSpeed ({hud['fall']})")
95 check(abs(hud["fall"] - 13 / 3) < 1e-9, f"{tag}: full spawn fallSpeed ({hud['fall']})")
96 check(abs(hud["clusterFall"] - 0.5 * 13 / 3) < 1e-9, f"{tag}: halved cluster float-down ({hud['clusterFall']})")
95 97 mini = page.locator("#minis .mini")
96 98 check(mini.count() >= 1, f"{tag}: at least one bot mini")
97 99 name = mini.first.locator(".mini-name").inner_text()
@@ -83,6 +83,7 @@ def run(page, tag):
83 schedule: app.battle && app.battle.schedule,
83 schedule: app.battle && app.battle.schedule,
84 jump: app.planet && app.planet.baseJumpHeight,
84 jump: app.planet && app.planet.baseJumpHeight,
85 fall: app.planet && app.planet.fallSpeed,
85 fall: app.planet && app.planet.fallSpeed,
86 clusterFall: app.planet && app.planet.clusterFallSpeed,
86 })""")
87 })""")
87 print("HUD", hud)
88 print("HUD", hud)
88 check(hud["hidden"] is False, f"{tag}: offline HUD visible")
89 check(hud["hidden"] is False, f"{tag}: offline HUD visible")
@@ -91,7 +92,8 @@ def run(page, tag):
91 check(hud["skill"] == "Skill 5%", f"{tag}: skill 5% ({hud['skill']})")
92 check(hud["skill"] == "Skill 5%", f"{tag}: skill 5% ({hud['skill']})")
92 check(hud["bots"] == 1, f"{tag}: one bot field")
93 check(hud["bots"] == 1, f"{tag}: one bot field")
93 check(abs(hud["jump"] - 1.5 * 13 / 2) < 1e-9, f"{tag}: +50% jump height ({hud['jump']})")
94 check(abs(hud["jump"] - 1.5 * 13 / 2) < 1e-9, f"{tag}: +50% jump height ({hud['jump']})")
94 check(abs(hud["fall"] - 0.5 * 13 / 3) < 1e-9, f"{tag}: halved fallSpeed ({hud['fall']})")
95 check(abs(hud["fall"] - 13 / 3) < 1e-9, f"{tag}: full spawn fallSpeed ({hud['fall']})")
96 check(abs(hud["clusterFall"] - 0.5 * 13 / 3) < 1e-9, f"{tag}: halved cluster float-down ({hud['clusterFall']})")
95 mini = page.locator("#minis .mini")
97 mini = page.locator("#minis .mini")
96 check(mini.count() >= 1, f"{tag}: at least one bot mini")
98 check(mini.count() >= 1, f"{tag}: at least one bot mini")
97 name = mini.first.locator(".mini-name").inner_text()
99 name = mini.first.locator(".mini-name").inner_text()
test/planet.test.js +12 −4
@@ -22,7 +22,8 @@ describe('Planet field and defaults', () =>
22 22 assert.equal(p.riseTime, 1.5);
23 23 assert.equal(p.colors.length, 5);
24 24 assert.equal(p.baseJumpHeight, 1.5 * 13 / 2);
25 assert.equal(p.fallSpeed, 0.5 * 13 / 3);
25 assert.equal(p.fallSpeed, 13 / 3);
26 assert.equal(p.clusterFallSpeed, 0.5 * 13 / 3);
26 27 });
27 28
28 29 it('clamps gravity, air and mass to the stage-3 ranges', () =>
@@ -119,16 +120,23 @@ describe('Launch and fall physics parameters', () =>
119 120 assert.ok(Math.abs(v2 / a2 - p.riseTime) < 1e-12);
120 121 });
121 122
122 it('fall speed is half the field height over fallTime (t1122), ratios kept', () =>
123 it('single-block fall speed is field height over fallTime; cluster float-down is half (t1124)', () =>
123 124 {
124 125 const slow = Planet.createPlanet({ fallTime: 5 });
125 126 const fast = Planet.createPlanet({ fallTime: 1 });
126 127 assert.equal(Planet.DESCENT_SPEED_SCALE, 0.5);
127 assert.equal(slow.fallSpeed, 0.5 * 13 / 5);
128 assert.equal(fast.fallSpeed, 0.5 * 13);
128 assert.equal(slow.fallSpeed, 13 / 5);
129 assert.equal(fast.fallSpeed, 13);
130 assert.equal(slow.clusterFallSpeed, 0.5 * 13 / 5);
131 assert.equal(fast.clusterFallSpeed, 0.5 * 13);
129 132 assert.ok(fast.fallSpeed > slow.fallSpeed);
130 133 // Relative difference between planets is unchanged (1 / fallTime).
131 134 assert.ok(Math.abs(fast.fallSpeed / slow.fallSpeed - 5) < 1e-12);
135 assert.ok(Math.abs(fast.clusterFallSpeed / slow.clusterFallSpeed - 5) < 1e-12);
136 // Apex ease duration is shared; cluster accel scales with the halved speed.
137 assert.ok(Math.abs(slow.clusterFallAccel - slow.clusterFallSpeed / slow.apexEaseTime) < 1e-12);
138 assert.ok(Math.abs(slow.fallAccel - slow.fallSpeed / slow.apexEaseTime) < 1e-12);
139 assert.equal(slow.clusterFallSpeed, Planet.DESCENT_SPEED_SCALE * slow.fallSpeed);
132 140 });
133 141 });
134 142
@@ -22,7 +22,8 @@ describe('Planet field and defaults', () =>
22 assert.equal(p.riseTime, 1.5);
22 assert.equal(p.riseTime, 1.5);
23 assert.equal(p.colors.length, 5);
23 assert.equal(p.colors.length, 5);
24 assert.equal(p.baseJumpHeight, 1.5 * 13 / 2);
24 assert.equal(p.baseJumpHeight, 1.5 * 13 / 2);
25 assert.equal(p.fallSpeed, 0.5 * 13 / 3);
25 assert.equal(p.fallSpeed, 13 / 3);
26 assert.equal(p.clusterFallSpeed, 0.5 * 13 / 3);
26 });
27 });
27
28
28 it('clamps gravity, air and mass to the stage-3 ranges', () =>
29 it('clamps gravity, air and mass to the stage-3 ranges', () =>
@@ -119,16 +120,23 @@ describe('Launch and fall physics parameters', () =>
119 assert.ok(Math.abs(v2 / a2 - p.riseTime) < 1e-12);
120 assert.ok(Math.abs(v2 / a2 - p.riseTime) < 1e-12);
120 });
121 });
121
122
122 it('fall speed is half the field height over fallTime (t1122), ratios kept', () =>
123 it('single-block fall speed is field height over fallTime; cluster float-down is half (t1124)', () =>
123 {
124 {
124 const slow = Planet.createPlanet({ fallTime: 5 });
125 const slow = Planet.createPlanet({ fallTime: 5 });
125 const fast = Planet.createPlanet({ fallTime: 1 });
126 const fast = Planet.createPlanet({ fallTime: 1 });
126 assert.equal(Planet.DESCENT_SPEED_SCALE, 0.5);
127 assert.equal(Planet.DESCENT_SPEED_SCALE, 0.5);
127 assert.equal(slow.fallSpeed, 0.5 * 13 / 5);
128 assert.equal(slow.fallSpeed, 13 / 5);
128 assert.equal(fast.fallSpeed, 0.5 * 13);
129 assert.equal(fast.fallSpeed, 13);
130 assert.equal(slow.clusterFallSpeed, 0.5 * 13 / 5);
131 assert.equal(fast.clusterFallSpeed, 0.5 * 13);
129 assert.ok(fast.fallSpeed > slow.fallSpeed);
132 assert.ok(fast.fallSpeed > slow.fallSpeed);
130 // Relative difference between planets is unchanged (1 / fallTime).
133 // Relative difference between planets is unchanged (1 / fallTime).
131 assert.ok(Math.abs(fast.fallSpeed / slow.fallSpeed - 5) < 1e-12);
134 assert.ok(Math.abs(fast.fallSpeed / slow.fallSpeed - 5) < 1e-12);
135 assert.ok(Math.abs(fast.clusterFallSpeed / slow.clusterFallSpeed - 5) < 1e-12);
136 // Apex ease duration is shared; cluster accel scales with the halved speed.
137 assert.ok(Math.abs(slow.clusterFallAccel - slow.clusterFallSpeed / slow.apexEaseTime) < 1e-12);
138 assert.ok(Math.abs(slow.fallAccel - slow.fallSpeed / slow.apexEaseTime) < 1e-12);
139 assert.equal(slow.clusterFallSpeed, Planet.DESCENT_SPEED_SCALE * slow.fallSpeed);
132 });
140 });
133});
141});
134
142
test/points.test.js +1 −1
@@ -111,7 +111,7 @@ describe('Points, landing and recolor', () =>
111 111 g.step(1);
112 112 assert.equal(g.blocks.length, 2);
113 113 // Let the first one land.
114 g.step(g.planet.fallTime / Planet.DESCENT_SPEED_SCALE + 0.5);
114 g.step(g.planet.fallTime + 0.2);
115 115 const landed = g.blocks.filter((b) => b.state === 'still');
116 116 assert.ok(landed.length >= 1);
117 117 for (const b of landed)
@@ -111,7 +111,7 @@ describe('Points, landing and recolor', () =>
111 g.step(1);
111 g.step(1);
112 assert.equal(g.blocks.length, 2);
112 assert.equal(g.blocks.length, 2);
113 // Let the first one land.
113 // Let the first one land.
114 g.step(g.planet.fallTime / Planet.DESCENT_SPEED_SCALE + 0.5);
114 g.step(g.planet.fallTime + 0.2);
115 const landed = g.blocks.filter((b) => b.state === 'still');
115 const landed = g.blocks.filter((b) => b.state === 'still');
116 assert.ok(landed.length >= 1);
116 assert.ok(landed.length >= 1);
117 for (const b of landed)
117 for (const b of landed)