Skip to content

Instantly share code, notes, and snippets.

View glebtsereteli's full-sized avatar
💭
Drawing in the Step event.

Gleb Tsereteli glebtsereteli

💭
Drawing in the Step event.
View GitHub Profile
@glebtsereteli
glebtsereteli / roomloader_export_screenshots.gml
Created June 11, 2025 15:14
A utility function for exporting a .zip archive with (all or specified) room screenshots using GMRoomLoader.
/// @func roomloader_export_screenshots()
/// @param {Array<Asset.GMRoom>} rooms=[all rooms] An array of rooms to export screenshots of.
/// @param {String} path=[prompt] The path to export the .zip to.
/// @descr Takes screenshots of all given rooms and exports them into a .zip archive at the given path.
/// Note: make sure to have the "Disable file system sandbox" setting disabled for your target platform.
function roomloader_export_screenshots(_rooms = asset_get_ids(asset_room), _path = undefined) {
with ({}) {
path = _path;
if (path == undefined) {
var _prefix = $"{game_project_name} Room Screenshots";
/// @func object_get_children()
/// @param {Asset.GMObject} parent The parent object to get children for.
/// @returns {Array<Asset.GMObject>}
/// @desc Returns an array of all child object indices for the given object.
function object_get_children(_parent) {
static _objects = asset_get_ids(asset_object);
return array_filter(_objects, method({_parent}, function(_obj) {
return object_is_ancestor(_obj, _parent);
}));
}
@glebtsereteli
glebtsereteli / debug_rooms.gml
Last active March 20, 2025 18:16
Provides control over room switching and displays room history in a neat Rooms debug overlay view. Call once at the start of the game.
/// @func debug_rooms()
/// @desc Provides control over room switching and displays room history in a neat Rooms debug overlay view.
/// Call once at the start of the game.
function debug_rooms() {
static __ = new(function() constructor {
__rooms = asset_get_ids(asset_room);
__names = array_map(__rooms, function(_room, _index) {
return $"{_index}: {room_get_name(_room)}";
});
__n = array_length(__rooms);
@glebtsereteli
glebtsereteli / debug_instances_imguigm.gml
Last active February 11, 2025 10:48
Displays the overall and per object amounts of instances in a neat ImGui window. Call inside an ImGui window/popup/menu.
/// @func debug_instances_imguigm()
/// @desc Displays the overall and per object amounts of instances in a neat ImGui table.
/// Call inside an ImGui window/popup/menu.
function debug_instances_imguigm() {
static _objects = array_map(asset_get_ids(asset_object), function(_obj) {
return {
__ref: _obj,
__name: object_get_name(_obj),
__n: 0,
};
@glebtsereteli
glebtsereteli / debug_instances.gml
Last active February 10, 2025 23:34
Displays the overall and per object amounts of instances in a neat Instances debug overlay view. Call anywhere in the project.
/// @func debug_instances()
/// @desc Displays the overall and per object amounts of instances in a neat Instances debug overlay __view.
/// Call anywhere in the project.
function debug_instances() {
static __ = new (function() constructor {
__objects = array_map(asset_get_ids(asset_object), function(_obj) {
return {
__ref: _obj,
__name: object_get_name(_obj),
__n: undefined,
@glebtsereteli
glebtsereteli / debug_resources.gml
Last active July 24, 2025 21:41
Displays the data fetched from debug_event("ResourceCounts") in a neat Resource Counts debug overlay view. Call anywhere in the project.
/// @func debug_resources()
/// @desc Displays the data fetched from debug_event("ResourceCounts") in a neat Resource Counts debug overlay view.
/// Call anywhere in the project.
function debug_resources() {
static __ = new (function() constructor {
var _refresh = function() {
if (not is_debug_overlay_open()) return;
struct_foreach(debug_event("ResourceCounts", true), function(_key, _value) {
self[$ _key] = _value;
});
@glebtsereteli
glebtsereteli / debug_resources_imguigm.gml
Last active May 25, 2025 20:43
Displays the data fetched from debug_event("ResourceCounts") in a neat ImGui_GM Table. Call inside an ImGui window/popup/menu.
/// @func debug_resources_imguigm()
/// @desc Displays the data fetched from debug_event("ResourceCounts") in a neat ImGui_GM Table.
/// Call inside an ImGui window/popup/menu.
function debug_resources_imguigm() {
{static _map = [
"listCount", "DS Lists",
"mapCount", "DS Maps",
"queueCount", "DS Queues",
"gridCount", "DS Grids",
"priorityCount", "DS Priority Queues",