fixed combo count
This commit is contained in:
@ -58,6 +58,7 @@ void Game::reset(int startLevel_) {
|
|||||||
_tetrisesMade = 0;
|
_tetrisesMade = 0;
|
||||||
_currentCombo = 0;
|
_currentCombo = 0;
|
||||||
_maxCombo = 0;
|
_maxCombo = 0;
|
||||||
|
_comboCount = 0;
|
||||||
// Initialize gravity using NES timing table (ms per cell by level)
|
// Initialize gravity using NES timing table (ms per cell by level)
|
||||||
gravityMs = gravityMsForLevel(_level, gravityGlobalMultiplier);
|
gravityMs = gravityMsForLevel(_level, gravityGlobalMultiplier);
|
||||||
fallAcc = 0; gameOver=false; paused=false;
|
fallAcc = 0; gameOver=false; paused=false;
|
||||||
@ -224,6 +225,10 @@ void Game::lockPiece() {
|
|||||||
// Update combo counters: consecutive clears increase combo; reset when no clear
|
// Update combo counters: consecutive clears increase combo; reset when no clear
|
||||||
_currentCombo += 1;
|
_currentCombo += 1;
|
||||||
if (_currentCombo > _maxCombo) _maxCombo = _currentCombo;
|
if (_currentCombo > _maxCombo) _maxCombo = _currentCombo;
|
||||||
|
// Count combos as any single clear that removes more than 1 line
|
||||||
|
if (cleared > 1) {
|
||||||
|
_comboCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Track tetrises made
|
// Track tetrises made
|
||||||
if (cleared == 4) {
|
if (cleared == 4) {
|
||||||
|
|||||||
@ -84,6 +84,7 @@ public:
|
|||||||
// Additional stats
|
// Additional stats
|
||||||
int tetrisesMade() const { return _tetrisesMade; }
|
int tetrisesMade() const { return _tetrisesMade; }
|
||||||
int maxCombo() const { return _maxCombo; }
|
int maxCombo() const { return _maxCombo; }
|
||||||
|
int comboCount() const { return _comboCount; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<int, COLS*ROWS> board{}; // 0 empty else color index
|
std::array<int, COLS*ROWS> board{}; // 0 empty else color index
|
||||||
@ -100,6 +101,7 @@ private:
|
|||||||
int _tetrisesMade{0};
|
int _tetrisesMade{0};
|
||||||
int _currentCombo{0};
|
int _currentCombo{0};
|
||||||
int _maxCombo{0};
|
int _maxCombo{0};
|
||||||
|
int _comboCount{0};
|
||||||
double gravityMs{800.0};
|
double gravityMs{800.0};
|
||||||
double fallAcc{0.0};
|
double fallAcc{0.0};
|
||||||
Uint64 _startTime{0}; // Performance counter at game start
|
Uint64 _startTime{0}; // Performance counter at game start
|
||||||
|
|||||||
@ -1212,7 +1212,7 @@ void GameRenderer::renderPlayingState(
|
|||||||
|
|
||||||
char totalStr[32]; snprintf(totalStr, sizeof(totalStr), "%d", totalBlocks);
|
char totalStr[32]; snprintf(totalStr, sizeof(totalStr), "%d", totalBlocks);
|
||||||
char tetrisesStr[32]; snprintf(tetrisesStr, sizeof(tetrisesStr), "%d", game->tetrisesMade());
|
char tetrisesStr[32]; snprintf(tetrisesStr, sizeof(tetrisesStr), "%d", game->tetrisesMade());
|
||||||
char maxComboStr[32]; snprintf(maxComboStr, sizeof(maxComboStr), "%d", game->maxCombo());
|
char maxComboStr[32]; snprintf(maxComboStr, sizeof(maxComboStr), "%d", game->comboCount());
|
||||||
|
|
||||||
// Use slightly smaller labels/values to match the compact look
|
// Use slightly smaller labels/values to match the compact look
|
||||||
const float labelX = statsX + 8.0f; // move labels more left
|
const float labelX = statsX + 8.0f; // move labels more left
|
||||||
@ -1231,7 +1231,7 @@ void GameRenderer::renderPlayingState(
|
|||||||
|
|
||||||
pixelFont->measure(maxComboStr, 0.55f, valW, valH);
|
pixelFont->measure(maxComboStr, 0.55f, valW, valH);
|
||||||
float comboX = statsX + statsW - valueRightPad - (float)valW;
|
float comboX = statsX + statsW - valueRightPad - (float)valW;
|
||||||
pixelFont->draw(renderer, labelX, summaryY + 44.0f, "MAX COMBO", 0.46f, labelMuted);
|
pixelFont->draw(renderer, labelX, summaryY + 44.0f, "COMBOS", 0.46f, labelMuted);
|
||||||
pixelFont->draw(renderer, comboX, summaryY + 44.0f, maxComboStr, 0.55f, summaryValueColor);
|
pixelFont->draw(renderer, comboX, summaryY + 44.0f, maxComboStr, 0.55f, summaryValueColor);
|
||||||
|
|
||||||
// Draw score panel (right side)
|
// Draw score panel (right side)
|
||||||
|
|||||||
Reference in New Issue
Block a user