feat: implement textured line clear effects and refine UI alignment

- **Visual Effects**: Upgraded line clear particles to use the game's block texture instead of simple circles, matching the reference web game's aesthetic.
- **Particle Physics**: Tuned particle velocity, gravity, and fade rates for a more dynamic explosion effect.
- **Rendering Integration**: Updated [main.cpp](cci:7://file:///d:/Sites/Work/tetris/src/main.cpp:0:0-0:0) and `GameRenderer` to pass the block texture to the effect system and correctly trigger animations upon line completion.
- **Menu UI**: Fixed [MenuState](cci:1://file:///d:/Sites/Work/tetris/src/states/MenuState.cpp:19:0-19:55) layout calculations to use fixed logical dimensions (1200x1000), ensuring consistent centering and alignment of the logo, buttons, and settings icon across different window sizes.
- **Code Cleanup**: Refactored `PlayingState` to delegate effect triggering to the rendering layer where correct screen coordinates are available.
This commit is contained in:
2025-11-21 21:19:14 +01:00
parent b5ef9172b3
commit 66099809e0
47 changed files with 5547 additions and 267 deletions

View File

@ -20,6 +20,12 @@
#pragma comment(lib, "mfuuid.lib")
#pragma comment(lib, "ole32.lib")
using Microsoft::WRL::ComPtr;
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#endif
Audio& Audio::instance(){ static Audio inst; return inst; }
@ -277,3 +283,40 @@ void Audio::shutdown(){
if(mfStarted){ MFShutdown(); mfStarted=false; }
#endif
}
// IAudioSystem interface implementation
void Audio::playSound(const std::string& name) {
// This is a simplified implementation - in a full implementation,
// you would load sound effects by name from assets
// For now, we'll just trigger a generic sound effect
// In practice, this would load a sound file and play it via playSfx
}
void Audio::playMusic(const std::string& name) {
// This is a simplified implementation - in a full implementation,
// you would load music tracks by name
// For now, we'll just start the current playlist
if (!tracks.empty() && !playing) {
start();
}
}
void Audio::stopMusic() {
playing = false;
}
void Audio::setMasterVolume(float volume) {
m_masterVolume = std::max(0.0f, std::min(1.0f, volume));
}
void Audio::setMusicVolume(float volume) {
m_musicVolume = std::max(0.0f, std::min(1.0f, volume));
}
void Audio::setSoundVolume(float volume) {
m_sfxVolume = std::max(0.0f, std::min(1.0f, volume));
}
bool Audio::isMusicPlaying() const {
return playing;
}

View File

@ -8,6 +8,7 @@
#include <thread>
#include <mutex>
#include <atomic>
#include "../core/interfaces/IAudioSystem.h"
struct AudioTrack {
std::string path;
@ -18,9 +19,20 @@ struct AudioTrack {
bool ok = false;
};
class Audio {
class Audio : public IAudioSystem {
public:
static Audio& instance();
// IAudioSystem interface implementation
void playSound(const std::string& name) override;
void playMusic(const std::string& name) override;
void stopMusic() override;
void setMasterVolume(float volume) override;
void setMusicVolume(float volume) override;
void setSoundVolume(float volume) override;
bool isMusicPlaying() const override;
// Existing Audio class methods
bool init(); // initialize backend (MF on Windows)
void addTrack(const std::string& path); // decode MP3 -> PCM16 stereo 44100
void addTrackAsync(const std::string& path); // add track for background loading
@ -57,4 +69,9 @@ private:
struct SfxPlay { std::vector<int16_t> pcm; size_t cursor=0; };
std::vector<SfxPlay> activeSfx;
std::mutex sfxMutex;
// Volume control
float m_masterVolume = 1.0f;
float m_musicVolume = 1.0f;
float m_sfxVolume = 1.0f;
};