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:
@ -181,3 +181,30 @@ void GlobalState::resetAnimationState() {
|
||||
fireworks.clear();
|
||||
lastFireworkTime = 0;
|
||||
}
|
||||
|
||||
void GlobalState::updateLogicalDimensions(int windowWidth, int windowHeight) {
|
||||
// For now, keep logical dimensions proportional to window size
|
||||
// You can adjust this logic based on your specific needs
|
||||
|
||||
// Option 1: Keep fixed aspect ratio and scale uniformly
|
||||
const float targetAspect = static_cast<float>(Config::Logical::WIDTH) / static_cast<float>(Config::Logical::HEIGHT);
|
||||
const float windowAspect = static_cast<float>(windowWidth) / static_cast<float>(windowHeight);
|
||||
|
||||
if (windowAspect > targetAspect) {
|
||||
// Window is wider than target aspect - fit to height
|
||||
currentLogicalHeight = Config::Logical::HEIGHT;
|
||||
currentLogicalWidth = static_cast<int>(currentLogicalHeight * windowAspect);
|
||||
} else {
|
||||
// Window is taller than target aspect - fit to width
|
||||
currentLogicalWidth = Config::Logical::WIDTH;
|
||||
currentLogicalHeight = static_cast<int>(currentLogicalWidth / windowAspect);
|
||||
}
|
||||
|
||||
// Ensure minimum sizes
|
||||
currentLogicalWidth = std::max(currentLogicalWidth, 800);
|
||||
currentLogicalHeight = std::max(currentLogicalHeight, 600);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"[GlobalState] Updated logical dimensions: %dx%d (window: %dx%d)",
|
||||
currentLogicalWidth, currentLogicalHeight, windowWidth, windowHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user