Finalize atmospheric logic and build v1.8.0

This commit is contained in:
Michael Howard 2026-04-23 16:29:54 -05:00
parent cdb274efe5
commit ae08bf6115
3 changed files with 9 additions and 10 deletions

Binary file not shown.

Binary file not shown.

View File

@ -884,17 +884,21 @@ int main(void)
SetMusicVolume(titleMusic, titleLoopFade * masterMusicVolume * (1.0f - crossfade)); SetMusicVolume(titleMusic, titleLoopFade * masterMusicVolume * (1.0f - crossfade));
// --- GLOBAL MUSIC VOLUME MANAGEMENT --- // --- GLOBAL TIME & AUDIO MANAGEMENT ---
float cycleLength = 300.0f;
if (currentState == GAMEPLAY) gameTime += GetFrameTime();
float timeOfDay = fmodf(gameTime, cycleLength) / cycleLength;
float sunAngle = timeOfDay * 2.0f * PI - PI/2.0f; float sunAngle = timeOfDay * 2.0f * PI - PI/2.0f;
float dayFactor = (sinf(sunAngle) + 1.0f) / 2.0f; float dayFactor = (sinf(sunAngle) + 1.0f) / 2.0f;
float quickMix = (dayFactor - 0.5f) * 5.0f + 0.5f; float quickMix = (dayFactor - 0.5f) * 5.0f + 0.5f;
if (quickMix > 1.0f) quickMix = 1.0f; if (quickMix > 1.0f) quickMix = 1.0f;
if (quickMix < 0.0f) quickMix = 0.0f; if (quickMix < 0.0f) quickMix = 0.0f;
SetMusicVolume(titleMusic, titleLoopFade * masterMusicVolume * (1.0f - crossfade));
SetMusicVolume(gameplayMusic, masterMusicVolume * crossfade * quickMix); SetMusicVolume(gameplayMusic, masterMusicVolume * crossfade * quickMix);
SetMusicVolume(nightMusic, masterMusicVolume * crossfade * (1.0f - quickMix)); SetMusicVolume(nightMusic, masterMusicVolume * crossfade * (1.0f - quickMix));
// Ensure streams are playing when crossfaded in // Ensure gameplay streams are playing when crossfaded in
if (crossfade > 0.01f) { if (crossfade > 0.01f) {
if (!IsMusicStreamPlaying(gameplayMusic)) PlayMusicStream(gameplayMusic); if (!IsMusicStreamPlaying(gameplayMusic)) PlayMusicStream(gameplayMusic);
if (!IsMusicStreamPlaying(nightMusic)) PlayMusicStream(nightMusic); if (!IsMusicStreamPlaying(nightMusic)) PlayMusicStream(nightMusic);
@ -1670,13 +1674,8 @@ int main(void)
// Draw Gameplay overlay if we entered gameplay // Draw Gameplay overlay if we entered gameplay
if (currentState == GAMEPLAY || currentState == PAUSE_MENU || currentState == CRAFTING_GUI) { if (currentState == GAMEPLAY || currentState == PAUSE_MENU || currentState == CRAFTING_GUI) {
// ---- Day / Night Cycle Calculations ---- // ---- Atmospheric Calculations (Previously global) ----
float cycleLength = 300.0f; // 5 minutes // lightLevel and blockTint are derived from the global dayFactor
float timeOfDay = fmodf(gameTime, cycleLength) / cycleLength;
// timeOfDay: 0.0 = Midnight, 0.25 = 6am (Sunrise), 0.5 = Noon, 0.75 = 6pm (Sunset)
float sunAngle = timeOfDay * 2.0f * PI - PI/2.0f;
float dayFactor = (sinf(sunAngle) + 1.0f) / 2.0f; // 0 (night) to 1 (day)
float lightLevel = 0.2f + 0.8f * dayFactor; // Ambient light multiplier float lightLevel = 0.2f + 0.8f * dayFactor; // Ambient light multiplier
Color blockTint = { (unsigned char)(255 * lightLevel), (unsigned char)(255 * lightLevel), (unsigned char)(255 * lightLevel), 255 }; Color blockTint = { (unsigned char)(255 * lightLevel), (unsigned char)(255 * lightLevel), (unsigned char)(255 * lightLevel), 255 };