refactor main game loop

This commit is contained in:
2025-12-19 20:07:48 +01:00
parent 783c12790d
commit 38dbc17ace
6 changed files with 1761 additions and 1948 deletions

1720
src/app/TetrisApp.cpp Normal file

File diff suppressed because it is too large Load Diff

29
src/app/TetrisApp.h Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include <memory>
// TetrisApp is the top-level application orchestrator.
//
// Responsibilities:
// - SDL/TTF init + shutdown
// - Asset/music loading + loading screen
// - Main loop + state transitions
//
// It uses a PIMPL to keep `TetrisApp.h` light (faster builds) and to avoid leaking
// SDL-heavy includes into every translation unit.
class TetrisApp {
public:
TetrisApp();
~TetrisApp();
TetrisApp(const TetrisApp&) = delete;
TetrisApp& operator=(const TetrisApp&) = delete;
// Runs the application until exit is requested.
// Returns a non-zero exit code on initialization failure.
int run();
private:
struct Impl;
std::unique_ptr<Impl> impl_;
};