Skip to content

Commit

Permalink
Adds function to deactivate interpolation for a single clock tick
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Apr 1, 2022
1 parent 7b6fbd4 commit 01da5cc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
10 changes: 5 additions & 5 deletions iota.yyp
Expand Up @@ -2,6 +2,7 @@
"resources": [
{"id":{"name":"obj_test_angle","path":"objects/obj_test_angle/obj_test_angle.yy",},"order":2,},
{"id":{"name":"scr_test_global_scope","path":"scripts/scr_test_global_scope/scr_test_global_scope.yy",},"order":5,},
{"id":{"name":"IotaSkipInterpolation","path":"scripts/IotaSkipInterpolation/IotaSkipInterpolation.yy",},"order":2,},
{"id":{"name":"obj_test_struct","path":"objects/obj_test_struct/obj_test_struct.yy",},"order":0,},
{"id":{"name":"obj_test_alarms","path":"objects/obj_test_alarms/obj_test_alarms.yy",},"order":3,},
{"id":{"name":"obj_player","path":"objects/obj_player/obj_player.yy",},"order":2,},
Expand Down Expand Up @@ -30,9 +31,8 @@
{"name":"Xbox One","path":"options/xboxone/options_xboxone.yy",},
{"name":"operagx","path":"options/operagx/options_operagx.yy",},
],
"isDnDProject": false,
"defaultScriptType": 1,
"isEcma": false,
"tutorialPath": "",
"configs": {
"name": "Default",
"children": [],
Expand All @@ -49,13 +49,13 @@
{"targets":-1,"resourceVersion":"1.3","name":"audiogroup_default","resourceType":"GMAudioGroup",},
],
"TextureGroups": [
{"isScaled":true,"autocrop":true,"border":2,"mipsToGenerate":0,"groupParent":null,"targets":-1,"resourceVersion":"1.3","name":"Default","resourceType":"GMTextureGroup",},
{"isScaled":true,"compressFormat":"bz2","autocrop":true,"border":2,"mipsToGenerate":0,"groupParent":null,"targets":-1,"resourceVersion":"1.3","name":"Default","resourceType":"GMTextureGroup",},
],
"IncludedFiles": [],
"MetaData": {
"IDEVersion": "2.3.7.606",
"IDEVersion": "2022.3.0.624",
},
"resourceVersion": "1.4",
"resourceVersion": "1.5",
"name": "Iota",
"tags": [],
"resourceType": "GMProject",
Expand Down
8 changes: 7 additions & 1 deletion options/main/options_main.yy
@@ -1,15 +1,21 @@
{
"option_gameguid": "e028baf3-597e-42bd-a661-30472965d4cc",
"option_gameid": "0",
"option_game_speed": 60,
"option_mips_for_3d_textures": false,
"option_draw_colour": 4294967295,
"option_window_colour": 255,
"option_steam_app_id": "0",
"option_sci_usesci": false,
"option_author": "",
"option_collision_compatibility": true,
"option_copy_on_write_enabled": true,
"option_lastchanged": "",
"option_spine_licence": false,
"resourceVersion": "1.2",
"option_template_image": "${base_options_dir}/main/template_image.png",
"option_template_icon": "${base_options_dir}/main/template_icon.png",
"option_template_description": null,
"resourceVersion": "1.4",
"name": "Main",
"tags": [],
"resourceType": "GMMainOptions",
Expand Down
23 changes: 22 additions & 1 deletion scripts/IotaClock/IotaClock.gml
Expand Up @@ -111,6 +111,7 @@ function IotaClock() constructor
static Tick = function()
{
IOTA_CURRENT_CLOCK = __identifier;
global.__iota_current_clock = self;

//Get the clamped delta time value for this GameMaker frame
//We clamp the bottom end to ensure that games still chug along even if the device is really grinding
Expand Down Expand Up @@ -175,6 +176,8 @@ function IotaClock() constructor
IOTA_CYCLES_FOR_CLOCK = undefined;
IOTA_CYCLE_INDEX = undefined;
IOTA_SECONDS_PER_CYCLE = undefined;

global.__iota_current_clock = undefined;
}

#endregion
Expand Down Expand Up @@ -291,6 +294,23 @@ function IotaClock() constructor
variable_instance_set(_scope, _out_name, variable_instance_get(_scope, _in_name));
}

static __VariableSkipInterpolation = function(_out_name, _scope)
{
var _child_data = __GetChildData(_scope);

var _variables = _child_data[__IOTA_CHILD.VARIABLES_INTERPOLATE];
var _j = 0;
repeat(array_length(_variables) div __IOTA_INTERPOLATED_VARIABLE.__SIZE)
{
if (_variables[@ _j + __IOTA_INTERPOLATED_VARIABLE.OUT_NAME] == _out_name)
{
_variables[@ _j + __IOTA_INTERPOLATED_VARIABLE.PREV_VALUE] = variable_instance_get(_scope, _variables[_j + __IOTA_INTERPOLATED_VARIABLE.IN_NAME]);
}

_j += __IOTA_INTERPOLATED_VARIABLE.__SIZE;
}
}

#endregion

#region Alarms
Expand Down Expand Up @@ -713,8 +733,9 @@ function IotaClock() constructor
__IotaTrace("Welcome to iota by @jujuadams! This is version " + __IOTA_VERSION + ", " + __IOTA_DATE);

global.__iota_unique_id = 0;
global.__iota_current_clock = undefined;

#macro IOTA_CURRENT_CLOCK global.__iota_current_clock
#macro IOTA_CURRENT_CLOCK global.__iota_current_identifier
#macro IOTA_CYCLES_FOR_CLOCK global.__iota_total_cycles
#macro IOTA_CYCLE_INDEX global.__iota_cycle_index
#macro IOTA_SECONDS_PER_CYCLE global.__iota_seconds_per_cycle
Expand Down
12 changes: 12 additions & 0 deletions scripts/IotaSkipInterpolation/IotaSkipInterpolation.gml
@@ -0,0 +1,12 @@
/// @param outName
/// @param [scope]

function IotaSkipInterpolation()
{
if (global.__iota_current_clock == undefined) __IotaError("Cannot use IotaSkipInterpolation() outside of a clock method");

var _out_name = argument[0];
var _scope = ((argument_count > 1) && (argument[1] != undefined))? argument[1] : self;

global.__iota_current_clock.__VariableSkipInterpolation(_out_name, _scope);
}
12 changes: 12 additions & 0 deletions scripts/IotaSkipInterpolation/IotaSkipInterpolation.yy
@@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "iota",
"path": "folders/iota.yy",
},
"resourceVersion": "1.0",
"name": "IotaSkipInterpolation",
"tags": [],
"resourceType": "GMScript",
}

0 comments on commit 01da5cc

Please sign in to comment.