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 Uses the scan line algorithm to render a polygon. | |
/// @param polygon {Integer} The id of the ds_list which stores pairwise positios of verticies. | |
/// @param outline {Boolean} Draw an outline instead of a filled shape. | |
/// @author Kat @katsaii | |
var count = ds_list_size(argument0) div 2; | |
if (count > 1) { | |
if (argument1) { | |
// outline | |
draw_primitive_begin(pr_linestrip); | |
draw_vertex( // last vertex |
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 Returns the type of data structure nested at an index of a ds_list. | |
/// @param id {Integer} The id of the ds_list to consider. | |
/// @param pos {Integer} The index of the ds_list to inspect. | |
/// @author Kat @katsaii | |
if (is_real(argument0[| argument1])) { | |
// copy the ds_list into a duplicate list that can be manipulated freely | |
var clone = ds_list_create(); | |
ds_list_copy(json_list, argument0); | |
// delete all records other than what's required | |
repeat (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
/// @desc Returns the type of data structure nested at a key of a ds_map. | |
/// @param id {Integer} The id of the ds_map to consider. | |
/// @param key {String} The key of the ds_map to inspect. | |
/// @author Kat @katsaii | |
if (is_real(argument0[? argument1])) { | |
// copy the ds_map into a duplicate map that can be manipulated freely | |
var clone = ds_map_create(); | |
ds_map_copy(clone, argument0); | |
// delete all records other than what's required | |
var key = ds_map_find_first(clone); |
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 Returns the size (in bytes) of a vertex format. | |
/// @param vformat {Integer} The vertex format to inspect. | |
/// @author Kat @katsaii | |
var max_size = 256; | |
/* 32 bytes is a realistic size. | |
* 256 is an, unrealistic, finite upper limit. | |
*/ | |
var buff = buffer_create(max_size, buffer_grow, 1); | |
var vbuff = vertex_create_buffer_from_buffer(buff, argument0); | |
var vbuff_buff = buffer_create_from_vertex_buffer(vbuff, buffer_grow, 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 Calculates a triangle wave. | |
/// @param angle {Real} The angle in degrees to consider. | |
return tri(degtorad(argument0)); |
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 Returns the id of the current script. | |
/// @author Kat @katsaii | |
var callstack = debug_get_callstack(); | |
var header = "gml_Script_"; | |
var delimiter = ":"; | |
for (var i = 1; i < array_length_1d(callstack); i++) { | |
var currentTrace = callstack[i]; | |
if (string_pos(header, currentTrace) == 1) { | |
var name = string_replace(currentTrace, header, ""); | |
var length = string_pos(delimiter, name); |
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 Returns a clone of an array. | |
/// @param variable {Array} The array to clone. | |
/// @author Kat @katsaii | |
if (array_length_1d(argument0) < 1) then return []; | |
argument0[0] = argument0[0]; | |
return argument0; |
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
#macro VAR "foo" | |
#macro GETTER variable_global_get(VAR) | |
#macro SETTER \ | |
for (var __value = GETTER;; { \ | |
if (is_real(__value) && __value > 0) { \ | |
variable_global_set(VAR, __value); \ | |
} else { \ | |
show_error("Global property '" + VAR + "' must be a positive number", false); \ | |
} \ | |
break; \ |
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; |
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])}} |
OlderNewer