Skip to content

Commit

Permalink
New lockdown mechanics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kroyee committed Mar 29, 2017
1 parent b89a7a2 commit a198863
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
37 changes: 29 additions & 8 deletions gamePlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);

Expand Down Expand Up @@ -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;
}
}

Expand Down
5 changes: 5 additions & 0 deletions gamePlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class gamePlay {
sendgameover=false;
winner=false;

lockdown=false;

rKey=false;
lKey=false;
dKey=false;
Expand Down Expand Up @@ -105,6 +107,9 @@ class gamePlay {
sf::Time countDownTime;
short countDowncount;

sf::Time lockDownTime;
bool lockdown;

sf::Uint16 linesSent;
sf::Uint16 linesRecieved;
short comboCount;
Expand Down

0 comments on commit a198863

Please sign in to comment.