This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gml_pragma("global", @' | |
// search for singletons | |
global.singletons = ds_list_create(); | |
for (var i = 0; object_exists(i); i++) { | |
if (object_prefix(i) == SINGLETON_PREFIX) { | |
ds_list_add(global.singletons, i); | |
// automatically insert singleton into the first room | |
object_set_persistent(i, true); | |
room_instance_add(room_first, 0, 0, i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @desc Draws a sprite in the middle of some fixed region, scaling where appropriate. | |
/// @param sprite {Integer} The id of the sprite to draw. | |
/// @param index {Integer} The image index of the sprite to draw. | |
/// @param x1 {Integer} The left-most position of the region. | |
/// @param y1 {Integer} The top-most position of the region. | |
/// @param x2 {Integer} The right-most position of the region. | |
/// @param y2 {Integer} The bottom-most position of the region. | |
/// @author Kat @katsaii | |
var x1 = argument2 < argument4 ? argument2 : argument4; | |
var y1 = argument3 < argument5 ? argument3 : argument5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @desc Draws the bounding box outline for this sprite. Only supports axis-aligned and oriented bounding boxes. | |
/// @param sprite {Real} The sprite to draw. | |
/// @param subimg {Real} The subimage of the sprite to use. | |
/// @param x {Real} X position. | |
/// @param y {Real} Y position. | |
/// @param xscale {Real} X scale. | |
/// @param yscale {Real} Y scale. | |
/// @param rot {Real} Rotation. | |
/// @param outline {Boolean} Whether to draw an outline or use a solid fill. | |
/// @author Kat @katsaii |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gml_pragma("global", @' | |
global.mouse_clicks = true;'); | |
/// @desc Disables/enables mouse clicks. | |
/// @param enable {Bool} Whether to enable mouse clicks. | |
/// @author Kat @katsaii | |
var enable = bool(argument0); | |
if (enable ^^ global.mouse_clicks) then global.mouse_clicks = enable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gml_pragma("global", @' | |
global.keyboard_mapping = undefined;'); | |
/// @desc Disables/enables the keyboard. | |
/// @param enable {Bool} Whether to enable the keyboard. | |
/// @author Kat @katsaii | |
if (argument0) { | |
// revert remaps | |
if (global.keyboard_mapping != undefined) { | |
var maps = global.keyboard_mapping; | |
var key = ds_map_find_first(maps); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set fmt=%1 | |
set url=%* | |
:: Strip fmt from url | |
set s=%fmt% | |
:loop | |
if [%s%] NEQ [] ( | |
set s=%s:~1% | |
set url=%url:~1% | |
goto loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- define boolean class | |
data Boolean : Set where | |
true false : Boolean | |
{- | |
truth table | |
(a.k.a xnor) | |
false | A and B | A < B | B | A > B | A | A xor B | A or B | A nor B | A == B | not A | A imply B | not B | A con B | A nand B | true | |
------|---------|-------|---|-------|---|---------|--------|---------|--------|-------|-----------|-------|---------|----------|------ | |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gml_pragma("forceinline"); | |
/// @desc Sets the window to the desired size and centres it. | |
/// @param w {Integer} The width to set the window to. | |
/// @param h {Integer} The height to set the window to. | |
window_set_rectangle( | |
(display_get_width() - argument0) div 2, | |
(display_get_height() - argument1) div 2, | |
argument0, argument1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///@param id,size,x,y | |
var G=argument0,W,H,S=argument1,i=0,j,k,a,b;if ds_exists(G,5){W=ds_grid_width(G)H=ds_grid_height(G)while(i<W*H){j=i%W;k=i++div W;a=argument2+j*S;b=argument3+k*S;draw_rectangle(a,b,a+S,b+S,1)draw_text(a,b,G[#j,k])}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @desc Finds the minimum distance between a point and a 2D line. | |
/// @param x {Real} The X position of the point. | |
/// @param y {Real} The Y position of the point. | |
/// @param u1 {Real} The first X position of the line. | |
/// @param w1 {Real} The first Y position of the line. | |
/// @param u2 {Real} The second X position of the line. | |
/// @param w2 {Real} The second Y position of the line. | |
var qx = argument0; | |
var qy = argument1; | |
var px = argument2; |