Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (21 sloc) 0.63 kB
#include <Gosu/Timing.hpp>
#include <unistd.h>
void Gosu::sleep(unsigned milliseconds)
{
usleep(milliseconds * 1000);
}
// Thanks to this blog for the unconvoluted code example:
// http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/
#include <mach/mach_time.h>
unsigned long Gosu::milliseconds()
{
static uint64_t firstTick = 0;
static mach_timebase_info_data_t info;
if (firstTick == 0)
{
mach_timebase_info(&info);
firstTick = mach_absolute_time();
}
uint64_t runtime = mach_absolute_time() - firstTick;
return runtime * info.numer / info.denom / 1000000.0;
}
Jump to Line
Something went wrong with that request. Please try again.