forked from Konstantin84UKR/Tetris_WebGPU
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.diff
More file actions
16 lines (15 loc) · 821 Bytes
/
patch.diff
File metadata and controls
16 lines (15 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--- src/controller.ts
+++ src/controller.ts
@@ -589,7 +589,12 @@
this.actionTimers.down %= SOFT_DROP_SPEED;
// Cap steps to prevent freeze/tunneling
// FIX: Latency - optimize maximum sonic drop steps
- const maxDrop = this.game.getGhostY() - this.game.activPiece.y;
+ // Only calculate getGhostY if we might actually do steps. If steps is larger than game height, cap it.
+ // The maximum drop distance is the playfield height (20) plus hidden rows.
+ if (steps > 22) {
+ steps = 22;
+ }
+ const maxDrop = Math.max(0, this.game.getGhostY() - this.game.activPiece.y);
if (steps > maxDrop) steps = maxDrop;
// Only move down if it's not going to lock immediately