Skip to content

Instantly share code, notes, and snippets.

function draw_hq_text_ext_transformed(_x,_y,_str,_sep,_width,_xscale,_yscale,_angle) {
//this function will automatically adjust the x, y, width, scakes and sep based on what the gui was scaled to before hand
//this is a drawing function for breaking out of the rescaling the gui layer to the highest possible quality before returning
static _is_browser = (os_browser != browser_not_a_browser);
var _w, _h;
//get the gui measurements
if (_is_browser){
_w = browser_width;
@tinkerer-red
tinkerer-red / CompatibilityScripts.gml
Created May 31, 2024 12:47
Every compatibility script from Game Maker Studio 1. The scripts come from the "compatibility" functions provided by Game Maker Studio 2. They are provided "as is", and compiler errors may be expected.
//-------------------------------------------------------------------------------------------------------\\
// __ It looks like you're looking for advice on initialization,
// / \ / Would you like help with that?
// | |
// @ @ Tinkerer_Red has removed all of the gml_pragma( "global", *);
// | | from the functions to prevent issues importing.
// || |/ If you would like to re-enable them just un comment them!
// || ||
// |\_/| He also commented out the MacroExpansion in
// \___/ `__global_object_depths`
@tinkerer-red
tinkerer-red / buffer_array.gml
Created September 17, 2024 19:55
buffer_array.gml
function buffer_array(_length, _type, _value=0) constructor {
width = _width;
height = _height;
size = width*height;
type = _type;
if (type == buffer_string)
|| (type == buffer_text) {
show_error("Type can not be a sting or text", true);
}
@tinkerer-red
tinkerer-red / hash_of_doom.gml
Last active September 27, 2024 12:34
Hash of Doom (execute_array)
function hash_of_doom(_funcArr) {
static __executors = (function(){
var _struct = {};
struct_set_from_hash(_struct, 0, function(_funcArr) { });
struct_set_from_hash(_struct, 1, function(_funcArr) { _funcArr[0]() });
struct_set_from_hash(_struct, 2, function(_funcArr) { _funcArr[0](); _funcArr[1]() });
struct_set_from_hash(_struct, 3, function(_funcArr) { _funcArr[0](); _funcArr[1](); _funcArr[2]() });
struct_set_from_hash(_struct, 4, function(_funcArr) { _funcArr[0](); _funcArr[1](); _funcArr[2](); _funcArr[3]() });
struct_set_from_hash(_struct, 5, function(_funcArr) { _funcArr[0](); _funcArr[1](); _funcArr[2](); _funcArr[3](); _funcArr[4]() });
struct_set_from_hash(_struct, 6, function(_funcArr) { _funcArr[0](); _funcArr[1](); _funcArr[2](); _funcArr[3](); _funcArr[4](); _funcArr[5]() });
@tinkerer-red
tinkerer-red / constructor_call.gml
Created October 5, 2024 05:24
An unfortunate way to call an arbitrary constructor dynamically.
function constructor_call_ext(_func, _args) {
static __executors = (function(){
var _struct = {};
struct_set_from_hash(_struct, 0, function(_func, _args) { return new _func( ); });
struct_set_from_hash(_struct, 1, function(_func, _args) { return new _func( _args[0] ); });
struct_set_from_hash(_struct, 2, function(_func, _args) { return new _func( _args[0], _args[1] ); });
struct_set_from_hash(_struct, 3, function(_func, _args) { return new _func( _args[0], _args[1], _args[2] ); });
struct_set_from_hash(_struct, 4, function(_func, _args) { return new _func( _args[0], _args[1], _args[2], _args[3] ); });
struct_set_from_hash(_struct, 5, function(_func, _args) { return new _func( _args[0], _args[1], _args[2], _args[3], _args[4] ); });
struct_set_from_hash(_struct, 6, function(_func, _args) { return new _func( _args[0], _args[1], _args[2], _args[3], _args[4], _args[5] ); });
@tinkerer-red
tinkerer-red / GC_LOG.gml
Last active October 24, 2024 18:14
Garbage Collecting Logging Macros
#region GC Timer Internals
//Beta IDE v2023.600.0.368 Beta Runtime v2023.600.0.387
// as of now, this number is 2 but might change in the future so best to calculate it on build, note this is not needed just increases accuracy
//forget the initial count as it builds new internals on first call
if (os_browser == browser_not_a_browser) gc_get_stats().num_objects_in_generation[0]
//find out the offset from simply running the function
var __gc_start = (os_browser != browser_not_a_browser) ? 0 : gc_get_stats().num_objects_in_generation[0]
global.__gc_log_offset = (os_browser != browser_not_a_browser) ? 0 : gc_get_stats().num_objects_in_generation[0]-__gc_start;
#endregion
@tinkerer-red
tinkerer-red / BinaryTestCases.gml
Last active October 16, 2024 20:24
Hex String To Int64, and Binary String To Int64
// 1. Upper Bound Positive (64-bit max positive value)
show_debug_message((0b0111111111111111111111111111111111111111111111111111111111111111 == __binaryTo64Bit("0b0111111111111111111111111111111111111111111111111111111111111111")) ? "Success" : $"{0b0111111111111111111111111111111111111111111111111111111111111111} != {__binaryTo64Bit("0b0111111111111111111111111111111111111111111111111111111111111111")}");
// 2. Lower Bound Positive (64-bit min positive value)
show_debug_message((0b1 == __binaryTo64Bit("0b1")) ? "Success" : $"{0b1} != {__binaryTo64Bit("0b1")}");
// 3. Upper Bound Negative (64-bit min negative value)
show_debug_message((0b1000000000000000000000000000000000000000000000000000000000000000 == __binaryTo64Bit("0b1000000000000000000000000000000000000000000000000000000000000000")) ? "Success" : $"{0b1000000000000000000000000000000000000000000000000000000000000000} != {__binaryTo64Bit("0b1000000000000000000000000000000000000000000000000000000000000000")}");
// 4. Lower Bound Negative (64-bit max n
@tinkerer-red
tinkerer-red / debugOverlayDemo.gml
Created October 20, 2024 13:09
debugOverlayDemo
show_debug_message("\n\n\n")
demo_view_pointer = dbg_view("Demo", true, 0, 0, display_get_gui_width(), display_get_gui_height());
dbg_section("", true);
dbg_text_separator("Views");
#region dbg_view
dbg_section("dbg_view", false);
@tinkerer-red
tinkerer-red / serialize
Created October 30, 2024 20:20
`serialize` removing functions from an output object
function serialize(_obj) {
if (is_handle(_obj) && script_exists(_obj)) return undefined; // strip functions as `undefined`
if (!is_array(_obj) && !is_struct(_obj)) return _obj;
// Check if it's an array or a plain object, then create a new instance accordingly
if (is_struct(_obj)) {
var _result = {};
var _names = struct_get_names(_obj)
var _length = array_length(_names);
for (var _i=0; _i<_length; _i++) {
@tinkerer-red
tinkerer-red / parent_constructor.gml
Created October 30, 2024 21:37
a macro for `parent_constructor`
#macro parent_constructor __parent_constructor(asset_get_index(_GMFUNCTION_))
/// @ignore
function __parent_constructor(_ref) {
if (struct_exists(static_get(_ref), "__parent_constructor__")) return static_get(_ref).__parent_constructor__;
var _constructor = undefined;
//check to see if this is the constructor
var _tags = asset_get_tags(_ref, asset_script)