feat: Add Firebase high score sync, menu music, and gameplay improvements
- Integrate Firebase Realtime Database for high score synchronization - Add cpr and nlohmann-json dependencies for HTTP requests - Implement async score loading from Firebase with local fallback - Submit all scores > 0 to Firebase in background thread - Always prompt for player name on game over if score > 0 - Add dedicated menu music system - Implement menu track support in Audio class with looping - Add "Every Block You Take.mp3" as main menu theme - Automatically switch between menu and game music on state transitions - Load menu track asynchronously to prevent startup delays - Update level speed progression to match web version - Replace NES frame-based gravity with explicit millisecond values - Implement 20-level speed table (1000ms to 60ms) - Ensure consistent gameplay between C++ and web versions - Fix startup performance issues - Move score loading to background thread to prevent UI freeze - Optimize Firebase network requests with 2s timeout - Add graceful fallback to local scores on network failure Files modified: - src/persistence/Scores.cpp/h - Firebase integration - src/audio/Audio.cpp/h - Menu music support - src/core/GravityManager.cpp/h - Level speed updates - src/main.cpp - State-based music switching, async loading - CMakeLists.txt - Add cpr and nlohmann-json dependencies - vcpkg.json - Update dependency list
This commit is contained in:
@ -14,19 +14,19 @@ double GravityManager::getGlobalMultiplier() const { return globalMultiplier; }
|
||||
|
||||
void GravityManager::setLevelMultiplier(int level, double m) {
|
||||
if (level < 0) return;
|
||||
int idx = level >= 29 ? 29 : level;
|
||||
int idx = level >= 19 ? 19 : level;
|
||||
levelMultipliers[idx] = std::clamp(m, 0.01, 100.0);
|
||||
}
|
||||
|
||||
double GravityManager::getLevelMultiplier(int level) const {
|
||||
int idx = level < 0 ? 0 : (level >= 29 ? 29 : level);
|
||||
int idx = level < 0 ? 0 : (level >= 19 ? 19 : level);
|
||||
return levelMultipliers[idx];
|
||||
}
|
||||
|
||||
double GravityManager::getMsForLevel(int level) const {
|
||||
int idx = level < 0 ? 0 : (level >= 29 ? 29 : level);
|
||||
double frames = static_cast<double>(FRAMES_TABLE[idx]) * levelMultipliers[idx];
|
||||
double result = frames * FRAME_MS * globalMultiplier;
|
||||
int idx = level < 0 ? 0 : (level >= 19 ? 19 : level);
|
||||
double baseMs = LEVEL_SPEEDS_MS[idx];
|
||||
double result = baseMs * levelMultipliers[idx] * globalMultiplier;
|
||||
return std::max(1.0, result);
|
||||
}
|
||||
|
||||
|
||||
@ -18,14 +18,11 @@ public:
|
||||
double getFpsForLevel(int level) const;
|
||||
|
||||
private:
|
||||
static constexpr double NES_FPS = 60.0988;
|
||||
static constexpr double FRAME_MS = 1000.0 / NES_FPS;
|
||||
static constexpr int FRAMES_TABLE[30] = {
|
||||
48,43,38,33,28,23,18,13,8,6,
|
||||
5,5,5,4,4,4,3,3,3,2,
|
||||
2,2,2,2,2,2,2,2,2,1
|
||||
static constexpr double LEVEL_SPEEDS_MS[20] = {
|
||||
1000.0, 920.0, 840.0, 760.0, 680.0, 600.0, 520.0, 440.0, 360.0, 280.0,
|
||||
200.0, 160.0, 160.0, 120.0, 120.0, 100.0, 100.0, 80.0, 80.0, 60.0
|
||||
};
|
||||
|
||||
double globalMultiplier{1.0};
|
||||
std::array<double,30> levelMultipliers{}; // default 1.0
|
||||
std::array<double,20> levelMultipliers{}; // default 1.0
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user