From a198863b90c18da6543b5a65895adb0a9f198a0c Mon Sep 17 00:00:00 2001 From: Olle Sam Date: Wed, 29 Mar 2017 16:20:45 +0200 Subject: [PATCH] New lockdown mechanics The piece lockdown was previously tied to the falling-speed, or if garbage was pushed up into the piece it would instantly lockdown. New system has added a static lockdown-time of 400ms in all cases. This works much more similar to what cultris uses and gives better control for softdroping with high stack or while garbage is being pushed up. --- gamePlay.cpp | 37 +++++++++++++++++++++++++++++-------- gamePlay.h | 5 +++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/gamePlay.cpp b/gamePlay.cpp index 1c161b8..6734268 100644 --- a/gamePlay.cpp +++ b/gamePlay.cpp @@ -34,6 +34,7 @@ void gamePlay::startGame() { oldbpmCount=0; autoaway=true; position=0; + lockdown=false; for (int i=0; i<10; i++) oldbpm[i]=0; setComboTimer(); @@ -105,9 +106,14 @@ void gamePlay::mDown() { if (possible()) { draw(); dclock.restart(); + lockdown=false; } - else + else { piece.mup(); + if (!lockdown) + lockDownTime=keyclock.getElapsedTime()+sf::milliseconds(400); + lockdown=true; + } } void gamePlay::hd() { @@ -269,13 +275,13 @@ void gamePlay::delayCheck() { piece.mdown(); if (possible()) { draw(); + lockdown=false; } else { piece.mup(); - addPiece(); - sendLines(field.clearlines()); - makeNewPiece(); - draw(); + if (!lockdown) + lockDownTime=keyclock.getElapsedTime()+sf::milliseconds(400); + lockdown=true; } dclock.restart(); } @@ -302,6 +308,21 @@ void gamePlay::delayCheck() { dKeyTime+=options.repeatSpeedDown; } + if (lockdown && keyclock.getElapsedTime() > lockDownTime) { + piece.mdown(); + if (!possible()) { + piece.mup(); + addPiece(); + sendLines(field.clearlines()); + makeNewPiece(); + draw(); + } + else { + piece.mup(); + lockdown=false; + } + } + if (keyclock.getElapsedTime() > comboStart+comboTime && comboCount!=0) { sf::Uint16 comboLinesSent = comboCount * pow(1.1, comboCount); @@ -505,9 +526,9 @@ void gamePlay::pushGarbage() { if (!possible()) { piece.mup(); - addPiece(); - sendLines(field.clearlines()); - makeNewPiece(); + if (!lockdown) + lockDownTime=keyclock.getElapsedTime()+sf::milliseconds(400); + lockdown=true; } } diff --git a/gamePlay.h b/gamePlay.h index 7adac9e..0d29f61 100644 --- a/gamePlay.h +++ b/gamePlay.h @@ -45,6 +45,8 @@ class gamePlay { sendgameover=false; winner=false; + lockdown=false; + rKey=false; lKey=false; dKey=false; @@ -105,6 +107,9 @@ class gamePlay { sf::Time countDownTime; short countDowncount; + sf::Time lockDownTime; + bool lockdown; + sf::Uint16 linesSent; sf::Uint16 linesRecieved; short comboCount;