Skip to content

Instantly share code, notes, and snippets.

View DragoniteSpam's full-sized avatar
🐉
I like dragons

Michael DragoniteSpam

🐉
I like dragons
View GitHub Profile
// Feather disable all
// @ignore
/*
function Drago3D_Internals() {
static Vertex = function(vbuff, x, y, z, nx, ny, nz, u, v, c, a) {
vertex_position_3d(vbuff, x, y, z);
vertex_normal(vbuff, nx, ny, nz);
vertex_colour(vbuff, c, a);
vertex_texcoord(vbuff, u, v);
};
@DragoniteSpam
DragoniteSpam / tilemap_to_vertex_buffer.gml
Created March 29, 2021 23:46
convert a game maker tilemap to a vertex buffer
function tilemap_to_vertex_buffer(tilemap, format) {
// vertex format: position, normal, texture
var vbuff = vertex_create_buffer();
vertex_begin(vbuff, format);
var ts_tileset = tilemap_get_tileset(tilemap);
var ts_tex = tileset_get_texture(ts_tileset);
var ts_uvs = tileset_get_uvs(ts_tileset);
var ts_tex_width = texture_get_texel_width(ts_tex);
var ts_tex_height = texture_get_texel_height(ts_tex);
var ts_tile_width = tilemap_get_tile_width(tilemap);
function draw_ngon(x, y, n, length, rot) {
draw_primitive_begin(pr_trianglefan);
draw_vertex_colour(x, y, c_white, 1);
for (var i = 0; i <= n; i++) {
var angle = 2 * pi / n * i + rot;
draw_vertex_colour(x + length * cos(angle), y - length * sin(angle), make_colour_hsv(255 / (n + 1) * i, 255, 255), 1);
}
draw_primitive_end();
}
enum InputVerbs {
A, B, X, Y,
LEFT, RIGHT, UP, DOWN,
LOOK_LEFT, LOOK_RIGHT, LOOK_UP, LOOK_DOWN,
PAD_LEFT, PAD_RIGHT, PAD_UP, PAD_DOWN,
PAUSE, UNPAUSE, RUN,
FRIEND_ATTACK,
FRIEND_DEFEND,
SHOULDERR2, // unused
SPELL_FIRE, SPELL_WATER, SPELL_THUNDER,
@DragoniteSpam
DragoniteSpam / ds_collection.gml
Created October 29, 2020 16:29
They're kinda like garbage collected ds_lists
function ds_collection_create() {
return [[undefined], 0, 0];
}
function ds_collection_add(collection, value) {
collection[@ 2]++;
var arr = collection[@ 0];
if (array_length(arr) <= collection[@ 1]) {
var new_arr = array_create(array_length(arr) * 2, undefined);
array_copy(new_arr, 0, arr, 0, array_length(arr));
@DragoniteSpam
DragoniteSpam / string_hex
Last active December 21, 2020 22:46
The opposite of hex().
function string_hex(value, padding) {
if (padding == undefined) padding = 0;
var s = sign(value);
var v = abs(value);
var output = "";
while (v > 0) {
var c = v & 0xf;
@DragoniteSpam
DragoniteSpam / hex.gml
Created October 19, 2020 02:47
No not the magical kind.
function hex(str) {
var result = 0;
// special unicode values
static ZERO = ord("0");
static NINE = ord("9");
static A = ord("A");
static F = ord("F");
@DragoniteSpam
DragoniteSpam / billboarding.vsh
Created September 1, 2020 05:47
GLSL ES; use with matrix_set and any of the draw_sprite functions in GameMaker. Fragment shader is just the passthrough shader.
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 object_space_pos = vec4(in_Position, 1.);
function NVec2(_x, _y) {
x = _x;
y = _y;
Add = function(_val) {
return new NVec2(x + _val.x, y + _val.y);
}
Sub = function(_val) {
return new NVec2(x - _val.x, y - _val.y);
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#pragma include("lighting.f.xsh")
/// https://github.com/GameMakerDiscord/Xpanda
uniform float lightBuckets;
varying vec4 v_lightColour;