Skip to content

Instantly share code, notes, and snippets.

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

gnysek gnysek

💭
Kuwabara! Kuwabara!
View GitHub Profile
//////////////
// Chapter 401
//////////////
// # = constant
// * = readonly
// @ = instance variable
// & = obsolete
// $ = US spelling
// £ = UK spelling
@gnysek
gnysek / foreach.gml
Last active February 20, 2024 14:18
Foreach GML
/// @return N/A (0)
///
/// Executes a method call for each element of the given struct/array/data structure.
/// This iterator is shallow and will not also iterate over nested structs/arrays (though
/// you can of course call foreach() inside the specified method)
///
/// This function can also iterate over all members of a ds_map, ds_list, or ds_grid.
/// You will need to specify a value for [dsType] to iterate over a data structure
///
/// The specified method is passed the following parameters:
@gnysek
gnysek / draw.gml
Created October 13, 2023 16:30
rectangle clip/cut
clip_x1 = 10;
clip_x2 = 500;
clip_y1 = 10;
clip_y2 = 100;
draw_set_color(c_white);
draw_set_alpha(1);
// set up shader:
shader_set(shd_clip_rect);
@gnysek
gnysek / buffedecrypt.gml
Created August 6, 2023 22:51
buffedecrypt.gml
// 39dll <3
function bufferencrypt(_key, b = global.buffer) {
bufferdecrypt(_key, b);
}
function bufferdecrypt(_key, _buff = global.buffer) {
var keylen = min(string_length(_key), 256);
if (keylen < 0) return false;
@gnysek
gnysek / singleton.gml
Created February 13, 2023 21:20
Singleton test
function Test() constructor {
static test = "--- singleton test";
}
Test();
function get_test() {
return static_get(Test);
}
@gnysek
gnysek / fnames.gml
Created December 19, 2022 08:43
fnames-2023.100.0.264
//////////////
// Chapter 401
//////////////
// # = constant
// * = readonly
// @ = instance variable
// & = obsolete
// $ = US spelling
// £ = UK spelling
@gnysek
gnysek / scr_mp_potential_step.gml
Created November 15, 2022 16:40
mp_potential_step but in pure GML
//
// based on https://github.com/YoYoGames/GameMaker-HTML5/blob/develop/scripts/functions/Function_MotionPlanning.js#L232
//
global.__mp_settings = {
maxrot: 30,
rotstep: 10,
ahead: 3,
onspot: true,
}
@gnysek
gnysek / new_array_func_test.gml
Last active October 25, 2022 10:04
tests of new GM 2022.11 functions
function timer(_name = "") constructor {
name = string(_name);
time = get_timer();
static total = function() {
var ddelta = get_timer() - time;
var ss = string_format( ddelta/repeats, 1, 10);
show_debug_message(string((ddelta)/1000) + "ms - " + ss + " per iteration " + name);
}
}
@gnysek
gnysek / debug.gml
Created October 12, 2022 12:35
gml debug stuff
{
release: GM_version, //Game version
app_build: GM_build_date,
config: os_get_config(),
paused: bool(os_is_paused()),
network_connected: bool(os_is_network_connected(false)),
language: os_get_language(),
region: os_get_region(),
runtime_version: GM_runtime_version,
app_start_time: date_current_datetime(),
// Simple particle system with blowing wind effect
// Note that this is *not* supposed to be an even vaguely accurate simulation
// There are also still a lot of optimisations possible
function _effect_windblown_particles() constructor
{
param_num_particles = 100;
param_particle_spawn_time = 100; // measured in milliseconds
param_particle_spawn_all_at_start = 0;
param_warmup_frames = 0;
param_sprite = _effect_windblown_particles_leaf_sprite;