mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
improved SDL_GetTicks without SDL, and getticks() replaced with it
This commit is contained in:
parent
ba92dd4b32
commit
ce08ec2a1f
@ -86,8 +86,6 @@ int textwidth(int siz, const string &str) {
|
||||
|
||||
char action;
|
||||
|
||||
int getticks() { return SDL_GetTicks(); }
|
||||
|
||||
bool currentlyConnecting() { return false; }
|
||||
bool currentlyConnected() { return false; }
|
||||
void viewAchievements() { printf("view Achievements\n"); }
|
||||
|
@ -276,8 +276,6 @@ void shareScore(MOBPAR_FORMAL) {
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
int nticks; int getticks() { return nticks; }
|
||||
|
||||
extern "C" void Java_com_roguetemple_hyperroid_HyperRogue_draw(MOBPAR_FORMAL) {
|
||||
// if(debfile) fprintf(debfile, "draw started.\n"), fflush(debfile);
|
||||
|
||||
|
4
init.cpp
4
init.cpp
@ -223,8 +223,6 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
|
||||
int touchedAt;
|
||||
|
||||
int getticks();
|
||||
|
||||
#if CAP_ANDROIDSHARE
|
||||
void shareScore(MOBPAR_FORMAL);
|
||||
#endif
|
||||
@ -233,7 +231,7 @@ void mobile_draw(MOBPAR_FORMAL) {
|
||||
|
||||
optimizeview();
|
||||
|
||||
int lastt = ticks; ticks = getticks();
|
||||
int lastt = ticks; ticks = SDL_GetTicks();
|
||||
if(lastt > ticks) lastt = ticks;
|
||||
int tdiff = ticks - lastt;
|
||||
|
||||
|
21
util.cpp
21
util.cpp
@ -6,16 +6,21 @@
|
||||
namespace hr {
|
||||
|
||||
#if CAP_TIMEOFDAY
|
||||
long long getms() {
|
||||
struct timeval tval;
|
||||
gettimeofday(&tval, NULL);
|
||||
return tval.tv_sec * 1000000 + tval.tv_usec;
|
||||
#if !CAP_SDL
|
||||
int lastusec;
|
||||
int uticks;
|
||||
|
||||
int SDL_GetTicks() {
|
||||
struct timeval tim;
|
||||
gettimeofday(&tim, NULL);
|
||||
int newusec = tim.tv_usec;
|
||||
uticks += newusec - lastusec;
|
||||
if(newusec <= lastusec)
|
||||
uticks += 1000000;
|
||||
lastusec = newusec;
|
||||
return uticks / 1000;
|
||||
}
|
||||
|
||||
#if !CAP_SDL
|
||||
int SDL_GetTicks() {
|
||||
return getms() / 1000;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user