Gamemaker: Quirks

In working with Gamemaker Studio, while it's built-in language, GML, is very much like C# with training wheels on, it just does some things differently from other programming languages.

An obvious example is that it doesn't need type declarations, and couldn't give less of a shit about line endings. The following would be required in C# and most programming languages:

string name = "Joel";
int age = 32;

In GML, you can get away with:

name = "Joel"
age = 32

While this is great and makes things quicker, it does kind of foster bad habits.

A less obvious example is that Gamemaker Studio treats strings as non-0 indexed char arrays, which is surprising in itself, but also that index 0 will return the data for index 1, rather than an error.

This was an infuriating quirk that messed with a text rendering script for like, ages. If I had the string "Peter Piper Picks Peppers" and tried to copy it out one character at a time from index 0, I'd get:

PPeter Piper Picks Peppers

"Why don't you just use draw_text()?" Because actual fonts are too huge, and as I was working with a princely 64x64 pixels, I needed fine control over every pixel and was rendering sprites as a custom font.


Popular posts from this blog

Fun with OTRS: Generic Agent

Rolling Health Meter

"I DON'T KNOW YOU": A Windows 10 tale