Skip to content

Instantly share code, notes, and snippets.

View gnysek's full-sized avatar
💭
Kuwabara! Kuwabara!

gnysek gnysek

💭
Kuwabara! Kuwabara!
View GitHub Profile
@tabularelf
tabularelf / scope rules.gml
Last active April 14, 2025 03:06
GameMaker function/method scope rules
/*
Scope Rules:
Caller == Whoever calls this method/function, is scoped to the caller. This is dependent on if there's an lvalue (lvalue.func()) or not. (for methods, the scope will be undefined).
Instance == Regardless of whoever calls this method/function, it's scoped to the instance that declared it and not the caller. (Or if using method, whatever instance that was passed in the scope that's not "undefined")
*/
// Declared in a script
// Scope == Caller, global (Will work no matter where you call it)
function myFunction() {
@tinkerer-red
tinkerer-red / CollisionArray.gml
Last active November 16, 2023 15:15
GML Collision Array Functions
#region jsDoc
/// @func collision_circle_array()
/// @desc This function is the same as the collision_circle() function, only instead of just detecting one instance / tile map in collision at a time, it will detect multiple instances or tile maps.
/// @param {Real} x1 : The x coordinate of the center of the circle to check.
/// @param {Real} y1 : The y coordinate of the center of the circle to check.
/// @param {Real} rad : The radius (distance in pixels from its center to its edge).
/// @param {Object} obj : Asset or Object Instance or Tile Map Element ID or Array An object, instance, tile map ID, keywords all/other, or array containing these items
/// @param {Boolean} prec : Whether the check is based on precise collisions (true, which is slower) or its bounding box in general (false, faster).
/// @param {Boolean} notme : Whether the calling instance, if relevant, should be excluded (true) or not (false).
/// @param {Array} array : The array to use to store the IDs of colliding instances
@meseta
meseta / Logger.gml
Last active December 23, 2023 22:40
GML Structured Logger
/** A logger instance that can be used for writing log messages
* @param {String} _name The logger's name. This will appear in any log messages produced by this logger
* @param {Struct} _bound_values Optional struct of bound values which will be included in all log messages produced by this logger
* @param {Struct.Logger} _root_logger The loot logger instance that is this logger's parent
* @author Meseta https://meseta.dev
*/
function Logger(_name="logger", _bound_values=undefined, _root_logger=undefined) constructor {
/* @ignore */ self.__name = _name;
/* @ignore */ self.__bound_values = (is_struct(_bound_values) ? _bound_values : {});
/* @ignore */ self.__file_handle = -1;