Skip to content

Instantly share code, notes, and snippets.

View attic-stuff's full-sized avatar
🎃
not eating canned air

attic-stuff attic-stuff

🎃
not eating canned air
View GitHub Profile
@attic-stuff
attic-stuff / sprite_get_index_from_frame.gml
Created October 31, 2025 18:20
takes a sprite frame, from stretched frames, and returns the image index for it
/*
* takes a sprite frame, from stretched frames, and returns the image index for it
* @param {Asset.GMSprite} sprite the sprite we're looking up
* @param {Real} frame the frame to check
* @return {Real}
*/
function sprite_get_index_from_frame(sprite, frame) {
var all_frames_information = sprite_get_info(sprite).frame_info;
@attic-stuff
attic-stuff / jasc_pal_library.gml
Last active July 29, 2025 17:19
small libary for reading/writing jasc-pal palette files
/**
* creates a struct object for managing a JASC-PAL color palette
* @param {Real} dot_pal_file the path to the .pal file
*/
function jasc_pal_pallette(dot_pal_file) constructor {
/**
* parses the .pal file
* @param {string} dot_pal_file the path toe the .pal file
*/
@attic-stuff
attic-stuff / chromatic_aberration.glsl
Created July 24, 2025 13:29
chromatic aberration shader
//this is the vertex shader
attribute vec3 in_Position;
attribute vec4 in_Colour;
attribute vec2 in_Texture_Coordinate;
varying vec2 vertex_texture_coordinate;
void main() {
vec4 vertex_model_position = vec4(in_Position, 1.0);
@attic-stuff
attic-stuff / room_region_to_scissor_region.gml
Created July 2, 2025 16:08
converts a region in the room to a gpu scissor region
/**
* converts a room region to a gpu scissor region
* @param {real} x the x position of the region origin
* @param {real} y the y position of the region origin
* @param {real} width the width of the region
* @param {real} height the height of the region
* @return {struct}
*/
function room_region_to_scissor_region(x, y, width, height) {
@attic-stuff
attic-stuff / noise_remap.gml
Last active May 10, 2025 17:22
remaps a noise texture to be cooler and better
/**
* remaps the values on a noise texture to fall between two new values
* @param {asset.GMSprite} noise_sprite the sprite that needs to be remapped
* @param {real} new_minimum the new minimum noise value
* @param {real} new_maximum the new maximum noise value
*/
function noise_remap(noise_sprite, new_minimum, new_maximum) {
var width = sprite_get_width(noise_sprite);
var height = sprite_get_height(noise_sprite);
@attic-stuff
attic-stuff / sprite_create_data_uri.gml
Last active August 24, 2025 16:25
creates a data uri from a sprite, assuming four channels of eight bit color
/**
* creates a data uri out of a sprite
* assumes rgba, 8bit
* @param {Asset.GMSprite} sprite_asset which sprite to convert to url
* @param {Real} [frame_number] which frame is being converted
* @return {String}
*/
function sprite_create_data_url(sprite_asset, frame_number = 0) {
static buffer_write_u32_backwards = function(buffer, value) {
@attic-stuff
attic-stuff / copy_game_path.gml
Created January 17, 2025 18:23
copies the path of the runner and game wad to the clipboard to use when u wanna open a second version of the game
function copy_game_path() {
clipboard_set_text($"{parameter_string(0)} -game {parameter_string(2)}");
}
@attic-stuff
attic-stuff / threedee_write_buffer_to_crocotile_obj.gml
Last active June 22, 2024 19:14
convert a vertex buffer into an obj file specifically for crocotile3d
function threedee_write_buffer_to_crocotile_obj(raw_vbo_buffer, name) {
static read_vertex = function(raw_buffer) {
var x_position = buffer_read(raw_buffer, buffer_f32);
var y_position = buffer_read(raw_buffer, buffer_f32);
var z_position = buffer_read(raw_buffer, buffer_f32);
var x_normal = buffer_read(raw_buffer, buffer_f32);
var y_normal = buffer_read(raw_buffer, buffer_f32);
var z_normal = buffer_read(raw_buffer, buffer_f32);
var r_color = buffer_read(raw_buffer, buffer_u8) / 255;
var g_color = buffer_read(raw_buffer, buffer_u8) / 255;
function lowkey_get_key_name(key) {
static names = undefined;
if (names == undefined) {
names = {};
names[$ vk_lshift] = "left shift";
names[$ vk_rshift] = "right shift";
names[$ vk_backspace] = "backspace";
names[$ vk_tab] = "tab";
names[$ vk_enter] = "enter";
names[$ vk_shift] = "either shift";
@attic-stuff
attic-stuff / tilemap_get_buffer.gml
Created December 31, 2023 01:35
functions for reading and writing tilemaps from and to buffers
/**
* writes a tilemap to a buffer
* @param {id.TileMapElement} map the tilemap source
* @return {id.Buffer}
*/
function buffer_get_tilemap(map) {
var width = tilemap_get_width(map);
var height = tilemap_get_height(map);
var buffer = buffer_create(width * height * buffer_sizeof(buffer_u32), buffer_fixed, 1);
for (var i = 0; i < width; i++) {