Nimbin2git.christianimmanuel.de / Games / strichmaennchen / time.h

strichmaennchen git · main

git clone https://git.christianimmanuel.de/games/strichmaennchen.gitwget https://git.christianimmanuel.de/games/strichmaennchen/archive/strichmaennchen.tar.gz
time.h 829 B · 36 lines raw
#ifndef TIME_H
#define TIME_H

#include <SDL3/SDL.h>

#include <stdbool.h>
#include "linalg.h"  // for Vec3


float Time_delta(Uint64* prev_ticks);

typedef struct {
    float hours;      // 0..24
    float minutes;    // 0..60
    float seconds;    // 0..60
    float timeScale;  // speed multiplier (1.0 = real-time, >1 = faster)
    float dayStart;  // 07:00
    float dayEnd; // 21:00

    float dayFactor;
    
    Vec3 sunDirection; // normalized vector
    Vec3 sunColor;     // RGB for sunlight
    Vec3 ambientColor; // global ambient light
} Time;

Time* Time_init(float timeScale);
void Time_update(Time* t, float deltaSeconds);

// optional helpers
float Time_getFractionOfDay(const Time* t);  // 0.0..1.0
void Time_computeSunPosition(Time* t);      // sets sunDirection & colors

void Time_destroy(Time* t);

#endif