fixed combo count
This commit is contained in:
@ -58,6 +58,7 @@ void Game::reset(int startLevel_) {
|
||||
_tetrisesMade = 0;
|
||||
_currentCombo = 0;
|
||||
_maxCombo = 0;
|
||||
_comboCount = 0;
|
||||
// Initialize gravity using NES timing table (ms per cell by level)
|
||||
gravityMs = gravityMsForLevel(_level, gravityGlobalMultiplier);
|
||||
fallAcc = 0; gameOver=false; paused=false;
|
||||
@ -224,6 +225,10 @@ void Game::lockPiece() {
|
||||
// Update combo counters: consecutive clears increase combo; reset when no clear
|
||||
_currentCombo += 1;
|
||||
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
|
||||
if (cleared == 4) {
|
||||
|
||||
@ -84,6 +84,7 @@ public:
|
||||
// Additional stats
|
||||
int tetrisesMade() const { return _tetrisesMade; }
|
||||
int maxCombo() const { return _maxCombo; }
|
||||
int comboCount() const { return _comboCount; }
|
||||
|
||||
private:
|
||||
std::array<int, COLS*ROWS> board{}; // 0 empty else color index
|
||||
@ -100,6 +101,7 @@ private:
|
||||
int _tetrisesMade{0};
|
||||
int _currentCombo{0};
|
||||
int _maxCombo{0};
|
||||
int _comboCount{0};
|
||||
double gravityMs{800.0};
|
||||
double fallAcc{0.0};
|
||||
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 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
|
||||
const float labelX = statsX + 8.0f; // move labels more left
|
||||
@ -1231,7 +1231,7 @@ void GameRenderer::renderPlayingState(
|
||||
|
||||
pixelFont->measure(maxComboStr, 0.55f, valW, valH);
|
||||
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);
|
||||
|
||||
// Draw score panel (right side)
|
||||
|
||||
Reference in New Issue
Block a user