Last active
August 29, 2015 14:01
-
-
Save hikari-no-yume/4f5259cde015a4d8f212 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <ctime> | |
#define DLLEXPORT extern "C" __declspec (dllexport) | |
DLLEXPORT double get_time() | |
{ | |
time_t currentTime, zeroTime = {0}; | |
time(¤tTime); | |
return difftime(currentTime, zeroTime); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global._get_time = external_define("ctime.dll", "get_time", dll_cdecl, ty_real, 0); | |
globalvar get_time; | |
get_time = "return external_call(global._get_time);" | |
object_event_add(PlayerControl,ev_create,0," | |
lastTime = execute_string(get_time); | |
time = lastTime; | |
"); | |
object_event_add(PlayerControl,ev_step,ev_step_begin," | |
time = execute_string(get_time); | |
time_delta = time - lastTime; | |
lastTime = time; | |
if (time_delta != 0) | |
{ | |
global.target_fps = 1/time_delta; | |
} | |
else | |
{ | |
global.target_fps = 1; | |
} | |
global.delta_factor = 30/global.target_fps; | |
global.ticks_per_virtual = global.target_fps/30; | |
global.skip_delta_factor = global.delta_factor/global.frameskip; | |
"); | |
//the first thing I thought of that existed through the entire game | |
//in case the game closes during a menu or something | |
object_event_add(RateController,ev_other, ev_game_end," | |
external_free('ctime.dll'); | |
"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment