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:
@ -43,6 +43,12 @@ public:
|
||||
void shuffle(); // randomize order
|
||||
void start(); // begin playback
|
||||
void toggleMute();
|
||||
|
||||
// Menu music support
|
||||
void setMenuTrack(const std::string& path);
|
||||
void playMenuMusic();
|
||||
void playGameMusic();
|
||||
|
||||
// Queue a sound effect to mix over the music (pcm can be mono/stereo, any rate; will be converted)
|
||||
void playSfx(const std::vector<int16_t>& pcm, int channels, int rate, float volume);
|
||||
void shutdown();
|
||||
@ -54,7 +60,10 @@ private:
|
||||
bool ensureStream();
|
||||
void backgroundLoadingThread(); // background thread function
|
||||
|
||||
std::vector<AudioTrack> tracks; int current=-1; bool playing=false; bool muted=false; std::mt19937 rng{std::random_device{}()};
|
||||
std::vector<AudioTrack> tracks;
|
||||
AudioTrack menuTrack;
|
||||
bool isMenuMusic = false;
|
||||
int current=-1; bool playing=false; bool muted=false; std::mt19937 rng{std::random_device{}()};
|
||||
SDL_AudioStream* audioStream=nullptr; SDL_AudioSpec outSpec{}; int outChannels=2; int outRate=44100; bool mfStarted=false;
|
||||
|
||||
// Threading support
|
||||
|
||||
Reference in New Issue
Block a user