Skip to content

Commit

Permalink
Merge in new lockdown system from master
Browse files Browse the repository at this point in the history
  • Loading branch information
kroyee committed Mar 29, 2017
2 parents df8d122 + a198863 commit 1fff5b2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
61 changes: 51 additions & 10 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,8 +308,44 @@ 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) {
linesSent = linesSent + comboCount * pow(1.1, comboCount);
sf::Uint16 comboLinesSent = comboCount * pow(1.1, comboCount);

bool blocked=false;
for (int i=0; i<comboLinesSent; i++)
if (garbage.size()) {
garbage.front().count--;
if (garbage.front().count == 0)
garbage.pop_front();
comboLinesSent--;
linesBlocked++;
blocked=true;
}

if (blocked) {
garbage.front().delay = keyclock.getElapsedTime()+sf::milliseconds(1500);
short total=0;
for (unsigned int x=0; x<garbage.size(); x++)
total+=garbage[x].count;
pendingText.setString(to_string(total));
}

linesSent += comboLinesSent;

cout << "Combo " << comboCount << " sent. Total " << linesSent << " SPM " << (((float)linesSent)/((float)keyclock.getElapsedTime().asSeconds()))*60.0 << endl;

Expand Down Expand Up @@ -402,7 +444,6 @@ void gamePlay::sendLines(sf::Vector2i lines) {
lines.x--;
linesBlocked++;
garbage.front().delay = keyclock.getElapsedTime()+sf::milliseconds(1500);
short total=0;
blocked=true;
}
short total=0;
Expand Down Expand Up @@ -485,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 1fff5b2

Please sign in to comment.