smooth scroll added

This commit is contained in:
2025-11-30 09:30:50 +01:00
parent 8279ccbe6d
commit 8b350bfb9e
6 changed files with 77 additions and 6 deletions

View File

@ -103,6 +103,24 @@ void Game::setPaused(bool p) {
paused = p;
}
void Game::setSoftDropping(bool on) {
if (softDropping == on) {
return;
}
double oldStep = softDropping ? (gravityMs / 5.0) : gravityMs;
softDropping = on;
double newStep = softDropping ? (gravityMs / 5.0) : gravityMs;
if (oldStep <= 0.0 || newStep <= 0.0) {
return;
}
double progress = fallAcc / oldStep;
progress = std::clamp(progress, 0.0, 1.0);
fallAcc = progress * newStep;
}
void Game::refillBag() {
bag.clear();
for (int i=0;i<PIECE_COUNT;++i) bag.push_back(static_cast<PieceType>(i));

View File

@ -28,7 +28,7 @@ public:
void tickGravity(double frameMs); // advance gravity accumulator & drop
void softDropBoost(double frameMs); // accelerate fall while held
void hardDrop(); // instant drop & lock
void setSoftDropping(bool on) { softDropping = on; } // mark if player holds Down
void setSoftDropping(bool on); // mark if player holds Down
void move(int dx); // horizontal move
void rotate(int dir); // +1 cw, -1 ccw (simple wall-kick)
void holdCurrent(); // swap with hold (once per spawn)