fixed timer functions
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@ -33,6 +33,7 @@
|
||||
#include "audio/MenuWrappers.h"
|
||||
#include "utils/ImagePathResolver.h"
|
||||
#include "graphics/renderers/GameRenderer.h"
|
||||
#include "core/Config.h"
|
||||
|
||||
// Debug logging removed: no-op in this build (previously LOG_DEBUG)
|
||||
|
||||
@ -629,6 +630,9 @@ int main(int, char **)
|
||||
}
|
||||
|
||||
Game game(startLevelSelection);
|
||||
// Apply global gravity speed multiplier from config
|
||||
game.setGravityGlobalMultiplier(Config::Gameplay::GRAVITY_SPEED_MULTIPLIER);
|
||||
game.reset(startLevelSelection);
|
||||
|
||||
// Initialize sound effects system
|
||||
SoundEffectManager::instance().init();
|
||||
@ -713,7 +717,7 @@ int main(int, char **)
|
||||
const double DAS = 170.0, ARR = 40.0;
|
||||
SDL_Rect logicalVP{0, 0, LOGICAL_W, LOGICAL_H};
|
||||
float logicalScale = 1.f;
|
||||
Uint64 lastMs = SDL_GetTicks();
|
||||
Uint64 lastMs = SDL_GetPerformanceCounter();
|
||||
bool musicStarted = false;
|
||||
bool musicLoaded = false;
|
||||
int currentTrackLoading = 0;
|
||||
@ -1084,9 +1088,12 @@ int main(int, char **)
|
||||
}
|
||||
|
||||
// --- Timing ---
|
||||
Uint64 now = SDL_GetTicks();
|
||||
double frameMs = double(now - lastMs);
|
||||
Uint64 now = SDL_GetPerformanceCounter();
|
||||
double frameMs = double(now - lastMs) * 1000.0 / double(SDL_GetPerformanceFrequency());
|
||||
lastMs = now;
|
||||
|
||||
// Cap frame time to avoid spiral of death (max 100ms)
|
||||
if (frameMs > 100.0) frameMs = 100.0;
|
||||
const bool *ks = SDL_GetKeyboardState(nullptr);
|
||||
bool left = state == AppState::Playing && ks[SDL_SCANCODE_LEFT];
|
||||
bool right = state == AppState::Playing && ks[SDL_SCANCODE_RIGHT];
|
||||
@ -1132,7 +1139,7 @@ int main(int, char **)
|
||||
{
|
||||
if (!game.isPaused()) {
|
||||
game.tickGravity(frameMs);
|
||||
game.addElapsed(frameMs);
|
||||
game.updateElapsedTime();
|
||||
|
||||
// Update line effect and clear lines when animation completes
|
||||
if (lineEffect.isActive()) {
|
||||
|
||||
Reference in New Issue
Block a user