Added challenge mode
This commit is contained in:
@ -867,6 +867,8 @@ void GameRenderer::renderPlayingState(
|
||||
|
||||
// Draw the game board
|
||||
const auto &board = game->boardRef();
|
||||
const auto &asteroidCells = game->asteroidCells();
|
||||
const bool challengeMode = game->getMode() == GameMode::Challenge;
|
||||
float impactStrength = 0.0f;
|
||||
float impactEased = 0.0f;
|
||||
std::array<uint8_t, Game::COLS * Game::ROWS> impactMask{};
|
||||
@ -954,7 +956,39 @@ void GameRenderer::renderPlayingState(
|
||||
bx += amplitude * std::sin(t * freq);
|
||||
by += amplitude * 0.75f * std::cos(t * (freq + 1.1f));
|
||||
}
|
||||
drawBlockTexture(renderer, blocksTex, bx, by, finalBlockSize, v - 1);
|
||||
|
||||
bool isAsteroid = challengeMode && asteroidCells[cellIdx].has_value();
|
||||
if (isAsteroid) {
|
||||
const AsteroidCell& cell = *asteroidCells[cellIdx];
|
||||
SDL_Color base{};
|
||||
switch (cell.type) {
|
||||
case AsteroidType::Normal: base = SDL_Color{172, 138, 104, 255}; break;
|
||||
case AsteroidType::Armored: base = SDL_Color{130, 150, 176, 255}; break;
|
||||
case AsteroidType::Falling: base = SDL_Color{210, 120, 82, 255}; break;
|
||||
case AsteroidType::Core: base = SDL_Color{198, 78, 200, 255}; break;
|
||||
}
|
||||
float hpScale = std::clamp(static_cast<float>(cell.hitsRemaining) / 3.0f, 0.25f, 1.0f);
|
||||
SDL_Color fill{
|
||||
static_cast<Uint8>(base.r * hpScale + 40 * (1.0f - hpScale)),
|
||||
static_cast<Uint8>(base.g * hpScale + 40 * (1.0f - hpScale)),
|
||||
static_cast<Uint8>(base.b * hpScale + 40 * (1.0f - hpScale)),
|
||||
255
|
||||
};
|
||||
drawRect(renderer, bx, by, finalBlockSize - 1, finalBlockSize - 1, fill);
|
||||
// Subtle outline to differentiate types
|
||||
SDL_Color outline = base;
|
||||
outline.a = 220;
|
||||
SDL_FRect border{bx + 1.0f, by + 1.0f, finalBlockSize - 2.0f, finalBlockSize - 2.0f};
|
||||
SDL_SetRenderDrawColor(renderer, outline.r, outline.g, outline.b, outline.a);
|
||||
SDL_RenderRect(renderer, &border);
|
||||
if (cell.gravityEnabled) {
|
||||
SDL_SetRenderDrawColor(renderer, 255, 230, 120, 180);
|
||||
SDL_FRect glow{bx + 2.0f, by + 2.0f, finalBlockSize - 4.0f, finalBlockSize - 4.0f};
|
||||
SDL_RenderRect(renderer, &glow);
|
||||
}
|
||||
} else {
|
||||
drawBlockTexture(renderer, blocksTex, bx, by, finalBlockSize, v - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1287,8 +1321,12 @@ void GameRenderer::renderPlayingState(
|
||||
|
||||
char levelStr[16];
|
||||
snprintf(levelStr, sizeof(levelStr), "%02d", game->level());
|
||||
char challengeLevelStr[16];
|
||||
snprintf(challengeLevelStr, sizeof(challengeLevelStr), "%02d/100", game->challengeLevel());
|
||||
char asteroidStr[32];
|
||||
snprintf(asteroidStr, sizeof(asteroidStr), "%d LEFT", game->asteroidsRemaining());
|
||||
|
||||
// Next level progress
|
||||
// Next level progress (endless only)
|
||||
int startLv = game->startLevelBase();
|
||||
int firstThreshold = (startLv + 1) * 10;
|
||||
int linesDone = game->lines();
|
||||
@ -1343,12 +1381,22 @@ void GameRenderer::renderPlayingState(
|
||||
statLines.push_back({scoreStr, 25.0f, 0.9f, valueColor});
|
||||
statLines.push_back({"LINES", 70.0f, 1.0f, labelColor});
|
||||
statLines.push_back({linesStr, 95.0f, 0.9f, valueColor});
|
||||
statLines.push_back({"LEVEL", 140.0f, 1.0f, labelColor});
|
||||
statLines.push_back({levelStr, 165.0f, 0.9f, valueColor});
|
||||
statLines.push_back({"NEXT LVL", 200.0f, 1.0f, labelColor});
|
||||
statLines.push_back({nextStr, 225.0f, 0.9f, nextColor});
|
||||
statLines.push_back({"TIME", 265.0f, 1.0f, labelColor});
|
||||
statLines.push_back({timeStr, 290.0f, 0.9f, valueColor});
|
||||
|
||||
if (game->getMode() == GameMode::Challenge) {
|
||||
statLines.push_back({"LEVEL", 140.0f, 1.0f, labelColor});
|
||||
statLines.push_back({challengeLevelStr, 165.0f, 0.9f, valueColor});
|
||||
statLines.push_back({"ASTEROIDS", 200.0f, 1.0f, labelColor});
|
||||
statLines.push_back({asteroidStr, 225.0f, 0.9f, nextColor});
|
||||
statLines.push_back({"TIME", 265.0f, 1.0f, labelColor});
|
||||
statLines.push_back({timeStr, 290.0f, 0.9f, valueColor});
|
||||
} else {
|
||||
statLines.push_back({"LEVEL", 140.0f, 1.0f, labelColor});
|
||||
statLines.push_back({levelStr, 165.0f, 0.9f, valueColor});
|
||||
statLines.push_back({"NEXT LVL", 200.0f, 1.0f, labelColor});
|
||||
statLines.push_back({nextStr, 225.0f, 0.9f, nextColor});
|
||||
statLines.push_back({"TIME", 265.0f, 1.0f, labelColor});
|
||||
statLines.push_back({timeStr, 290.0f, 0.9f, valueColor});
|
||||
}
|
||||
|
||||
if (debugEnabled) {
|
||||
SDL_Color debugLabelColor{150, 150, 150, 255};
|
||||
|
||||
Reference in New Issue
Block a user