mirror of
https://github.com/NoelFB/blah.git
synced 2025-06-29 19:25:26 +08:00
more precise timing
renamed Time::elapsed -> Time::seconds, change type to double updated game to store ticks (microseconds) instead of milliseconds for better update precision
This commit is contained in:
@ -5,14 +5,20 @@ namespace Blah
|
||||
{
|
||||
struct Time
|
||||
{
|
||||
// uptime, in milliseconds
|
||||
static uint64_t milliseconds;
|
||||
// ticks per second (microseconds, in this case)
|
||||
static constexpr uint64_t ticks_per_second = 1000000;
|
||||
|
||||
// uptime, in ticks
|
||||
static uint64_t ticks;
|
||||
|
||||
// uptime, in seconds
|
||||
static float elapsed;
|
||||
static double seconds;
|
||||
|
||||
// previous frame uptime, in ticks
|
||||
static uint64_t previous_ticks;
|
||||
|
||||
// previous frame uptime, in seconds
|
||||
static float previous_elapsed;
|
||||
static double previous_seconds;
|
||||
|
||||
// delta time from last frame
|
||||
static float delta;
|
||||
@ -21,10 +27,10 @@ namespace Blah
|
||||
static float pause_timer;
|
||||
|
||||
// pauses the entire application for the given time
|
||||
static void pause_for(float time);
|
||||
static void pause_for(float duration);
|
||||
|
||||
// returns true on the given time interval
|
||||
static bool on_interval(float time, float delta, float interval, float offset);
|
||||
static bool on_interval(double time, float delta, float interval, float offset);
|
||||
|
||||
// returns true on the given time interval
|
||||
static bool on_interval(float delta, float interval, float offset);
|
||||
@ -33,10 +39,10 @@ namespace Blah
|
||||
static bool on_interval(float interval, float offset = 0);
|
||||
|
||||
// returns true when the given timestamp is passed
|
||||
static bool on_time(float time, float timestamp);
|
||||
static bool on_time(double time, double timestamp);
|
||||
|
||||
// returns true between time intervals
|
||||
static bool between_interval(float time, float interval, float offset);
|
||||
static bool between_interval(double time, float interval, float offset);
|
||||
|
||||
// returns true between time intervals
|
||||
static bool between_interval(float interval, float offset = 0);
|
||||
|
@ -61,9 +61,9 @@ namespace Blah
|
||||
int m_last_value_i = 0;
|
||||
bool m_pressed = false;
|
||||
bool m_released = false;
|
||||
float m_last_press_time = -1;
|
||||
float m_last_release_time = -1;
|
||||
float m_repeat_press_time = -1;
|
||||
double m_last_press_time = -1;
|
||||
double m_last_release_time = -1;
|
||||
double m_repeat_press_time = -1;
|
||||
|
||||
public:
|
||||
VirtualAxis& add_keys(Key negative, Key positive);
|
||||
|
@ -61,9 +61,9 @@ namespace Blah
|
||||
bool m_down = false;
|
||||
bool m_pressed = false;
|
||||
bool m_released = false;
|
||||
float m_last_press_time = -1;
|
||||
float m_last_release_time = -1;
|
||||
float m_repeat_press_time = -1;
|
||||
double m_last_press_time = -1;
|
||||
double m_last_release_time = -1;
|
||||
double m_repeat_press_time = -1;
|
||||
|
||||
public:
|
||||
VirtualButton& add_key(Key key);
|
||||
|
@ -70,9 +70,9 @@ namespace Blah
|
||||
bool m_released = false;
|
||||
|
||||
float m_i_deadzone;
|
||||
float m_last_press_time = -1;
|
||||
float m_last_release_time = -1;
|
||||
float m_repeat_press_time = -1;
|
||||
double m_last_press_time = -1;
|
||||
double m_last_release_time = -1;
|
||||
double m_repeat_press_time = -1;
|
||||
|
||||
public:
|
||||
VirtualStick();
|
||||
|
Reference in New Issue
Block a user