<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Sean O'Donnell's GameMaker Notes]]></title><description><![CDATA[Sean O'Donnell's GameMaker Notes]]></description><link>https://sean-odonnell-gamedev.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 20:14:40 GMT</lastBuildDate><atom:link href="https://sean-odonnell-gamedev.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[GameMaker Macros: A Designer's Best Friend?]]></title><description><![CDATA[Keep every tunable number in one GameMaker script of macros. What a playtest did to the values, and the dependencies the script can’t show.]]></description><link>https://sean-odonnell-gamedev.hashnode.dev/gamemaker-macros-a-designers-best-friend</link><guid isPermaLink="true">https://sean-odonnell-gamedev.hashnode.dev/gamemaker-macros-a-designers-best-friend</guid><category><![CDATA[GameDev]]></category><category><![CDATA[gamemaker]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Game Development]]></category><category><![CDATA[#Game Design]]></category><category><![CDATA[Game Maker]]></category><dc:creator><![CDATA[Sean O'Donnell]]></dc:creator><pubDate>Mon, 16 Nov 2026 00:28:03 GMT</pubDate><content:encoded><![CDATA[<p><strong>Don't let designers touch code!</strong> Is that a joke? Yes, absolutely. But it quietly points to something we know about working in groups: not everybody knows the same things, has the same competencies, or does things the same way. As developers, the way we design systems can save a lot of time and work by thinking ahead of the people who will need to work with them. One method for that in GameMaker is using macros.</p>
<p>This post covers how one script of macros held the tunable numbers in a student platformer. It also covers what happened when a class playtest changed the feel of the game, and what I'd watch for if you try it.</p>
<h2>The Problem</h2>
<p>The case where this came up was a platformer being made by a small team of students. Lots of values were directly tied to character movement, resources, economy, and so on. Those values were unlikely to be nailed down in the documentation stage and would need refining in testing, which guaranteed that team members would need to alter things.</p>
<p>There are plenty of arguments for putting those values in one or more controller objects, but simplicity seemed key. Reducing the need for team members to be deeply familiar with the code would limit fatigue and potential mistakes.</p>
<p>Picture the alternative. Every speed typed into the object that uses it. Retuning the jump means searching the whole project for the number 30 and hoping nothing else uses 30.</p>
<h2>What I Built</h2>
<p>One script holds the values meant to be tuned, as <a href="https://manual.gamemaker.io/lts/en/GameMaker_Language/GML_Overview/Variables/Constants.htm">macros</a>. A macro is a global name for a value or an expression. A plain value can't change while the game runs.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6af6ab29d3d6abc0f3d96aac/eb44189d-92b8-43e4-b73c-63809ecff3e2.png" alt="macros-script" style="display:block;margin:0 auto" />

<p>The script opens with its one rule. GDD and TDD are the game design document and the technical design document.</p>
<pre><code class="language-gml">// Every GDD/TDD number is here and nowhere else.  Other code uses the macro name,
// never the number itself, so a design change is a quick edit.
// Names match the GDD variables so the GDD can be searched against the code.
</code></pre>
<p>"Nowhere else" is the goal. The result is a little messier, and section 6 has the exceptions.</p>
<p>There are three kinds of macros in the script, all simple.</p>
<ul>
<li>Plain values, like <code>WALK_SPEED</code>, set a number for a mechanic.</li>
<li>Derived values, like <code>TERMINAL_FALL_SPEED</code>, are built from other macros.</li>
<li>Booleans, like <code>DEV_CHECKS</code>, turn features on or off.</li>
</ul>
<pre><code class="language-gml">#macro WALK_SPEED 10
#macro JUMP_SPEED 20
#macro TERMINAL_FALL_SPEED (JUMP_SPEED * 3)
#macro DEV_CHECKS true
</code></pre>
<p><code>DEV_CHECKS</code> controls a suite of developer checks used only for testing. The setup checks read it, so one line turns all of them off for a release build.</p>
<p>The plain and derived ones are called by other scripts and objects, and set a baseline for practically everything. The values are transformed elsewhere, in the part of the code that isn't really meant to be tinkered with without familiarity. Here is the walking code reading two of them.</p>
<pre><code class="language-gml">xspeed = _dir * (global.input.run.held ? RUN_SPEED : WALK_SPEED);
</code></pre>
<p>Fall damage is the cleanest example. The formula lives in the player object, and nobody has to open it to tune it.</p>
<pre><code class="language-gml">if (_hurt &amp;&amp; landing_speed &gt; FALL_DAMAGE_SPEED)
{
	hurt_player(floor((landing_speed - FALL_DAMAGE_SPEED) / FALL_DAMAGE_DIVISOR));
}
</code></pre>
<p>Change <code>FALL_DAMAGE_DIVISOR</code> in the macro script and falls hurt more or less. The logic stays put.</p>
<p>Numbers that depend on an upgrade level, like the player weapon's, can't be one name. Those sit in a function in the same script.</p>
<h2>Why Macros</h2>
<p>There are a myriad of ways this could have been done. For example:</p>
<ul>
<li>numbers typed where they are used</li>
<li>global variables</li>
<li>a controller object holding the values</li>
<li>enums</li>
<li>values read from an ini or JSON file at run time</li>
</ul>
<p>Typing numbers in place is the fastest to write and the worst to retune. Global variables and a controller object can both change while the game runs, which is great for live tuning and sliders. The cost is that any code can overwrite a value by accident. Enums hold whole numbers (the manual says int64), and plenty of tuning numbers aren't whole. The brightness limit here is 0.5. A file read at run time lets you tune without rebuilding, but you now own the loading code and the missing-file case. (I did use a JSON file for the game's dialogue. That's a different problem.)</p>
<p>Here is what tipped it toward macros.</p>
<p>The game freezes a room by deactivating its instances, and a controller full of values would be one more thing to keep awake. The manual warns that a deactivated persistent instance isn't carried to the next room unless it's activated first. A macro has no instance to deactivate.</p>
<p>A controller also has to exist, in the right room, with its Create event already run. In this project a controller placed in a room existed before its Create ran. Code that checked for it and then read its variables crashed with "not set before reading it." A macro is never unset.</p>
<p>Constants and state stay separate this way. Max HP is a macro and isn't stored in the save file, because it never changes. Values that do change live in objects.</p>
<p>Derived values can't go stale. A macro built from another macro gives the result each time it's used, so <code>TERMINAL_FALL_SPEED</code> follows <code>JUMP_SPEED</code> with no extra code.</p>
<p>What I gave up is the ability to change a macro while the game runs. No sliders, no live tuning, and every tweak needs a rebuild. That matters most for anything the player adjusts. Brightness is a setting that changes at run time, so its macros (<code>BRIGHTNESS_MIN</code>, <code>BRIGHTNESS_MAX</code> and <code>BRIGHTNESS_STEP</code>) only set the limits and the step. The current value lives elsewhere.</p>
<p>Advancement is the same split. The player weapon is the thing that grows. Its three upgrade levels (damage, speed and reach, 0 to 2 each) are variables in the player's data object, and they're bought from a shop. A function in the macro script turns those levels into the weapon's damage, reach and delay. The macros only say how many stages there are, how many the first area sells, and what each stage costs.</p>
<p>The catch is that a macro can't follow a variable. Anything built on a macro stays put when a variable changes, which is why the weapon's numbers sit in a function and not in derived macros.</p>
<h2>What It Did, Technically</h2>
<p>The class playtest was the test. Six lines changed.</p>
<ul>
<li><code>WALK_SPEED</code>, 15 to 10</li>
<li><code>RUN_SPEED</code>, 25 to 15</li>
<li><code>JUMP_SPEED</code>, 30 to 20</li>
<li><code>WALL_SLIDE_SPEED</code>, 15 to 5</li>
<li><code>FLOAT_FALL_SPEED</code>, 10 to 7</li>
<li><code>GRAVITY</code>, 2 to 1</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6af6ab29d3d6abc0f3d96aac/b98e3f9d-ca28-4bfe-8778-efef690750e2.png" alt="six-line-edits-table" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6af6ab29d3d6abc0f3d96aac/97d82bba-cecf-456c-ba11-c52c37d92ca4.png" alt="macros-diff" style="display:block;margin:0 auto" />

<p>Eight more macros followed without being touched. <code>D_JUMP_SPEED</code>, <code>WALL_JUMP_SPEED</code>, <code>TERMINAL_FALL_SPEED</code>, <code>FALL_DAMAGE_SPEED</code> and <code>STOMP_BOUNCE_SPEED</code> came from the jump speed. <code>DRIFT_SPEED</code> came from the walk speed. <code>WALL_JUMP_PUSH</code> and <code>STRING_MAX_SPEED</code> (the rope swing's top speed) came from the run speed. Terminal fall speed went from 90 to 60 and the fall damage threshold from 60 to 40.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6af6ab29d3d6abc0f3d96aac/b178d589-6362-4cd2-885b-ad4d233298a2.png" alt="macros-dependency-diagram" style="display:block;margin:0 auto" />

<p>Nothing else in the macro script is built on the wall slide, float or gravity values. Gravity still reached further than the script shows. The player, the enemies and the player's rope swing all read it.</p>
<p>The macro script shows only half the relationships. Take fall damage again. The player's fall is capped at <code>TERMINAL_FALL_SPEED</code>, which is three jump speeds. The player only takes damage above <code>FALL_DAMAGE_SPEED</code>, which is two. The damage is the speed over that threshold, divided by <code>FALL_DAMAGE_DIVISOR</code> and rounded down. Put those together and the worst possible fall does <code>JUMP_SPEED</code> divided by the divisor, rounded down.</p>
<p>With a divisor of 3, that was 10 HP of the player's 40 at a jump speed of 30. At 20 it's 6. The playtest edit to the jump cut the worst fall by 4 HP, and no line in the macro script says so.</p>
<h2>What It Did For The Team</h2>
<p>The goal was that nobody needs to understand the movement code to change how the game feels. The playtest was the first real check of that. The retuning was six numbers in one file, and none of the movement code changed.</p>
<p>The names also match the design document. A teammate reading the GDD can search the code for <code>WALK_SPEED</code> and land on the number.</p>
<p>A shared file is a shared point of collision, though. After one merge, <code>WALK_SPEED</code> and <code>RUN_SPEED</code> were each defined twice and the project wouldn't compile. That failure is loud, and the fix was two lines. I'll take loud over quiet. Two assignments to the same variable in a controller would have just run, and the last one would have won.</p>
<h2>What I Would Change</h2>
<p>The comment at the top says every number lives in that script. The same playtest changed three things outside it. One was an enemy's height, set in its own Create event. Another was a new creature placed in a room with its HP set on the instance. The last was a light source's power and position, also set in the room. The weapon's upgrade values are arrays inside a function, so they aren't macros at all. And the design document still lists the old playtest numbers, so the numbers now live in two places and only one of them is current.</p>
<p>Next time I'd sort the numbers on day one into three groups: fixed, tuned in testing, and growing with play. The weapon's numbers grow, so they live in a function that reads each upgrade level, which a macro can't do.</p>
<h2>Things To Know Before You Try It</h2>
<p>From the manual:</p>
<ul>
<li>A definition takes no equals sign and no semicolon at the end. <code>#macro TOTAL_WEAPONS 10</code> is right. <code>#macro TOTAL_WEAPONS = 10;</code> isn't.</li>
<li>Assigning to a macro crashes the game.</li>
<li>Define macros in a script asset, outside any function, and keep them together.</li>
<li>A macro can hold an expression, and an expression macro gives the result each time it's used. The manual's example picks a random color, so you get a different one every use.</li>
</ul>
<p>I wasn't sure whether the parentheses in <code>(JUMP_SPEED * 3)</code> matter. A two-macro test settles it. The macros go in a script.</p>
<pre><code class="language-gml">#macro BARE_SUM 1 + 2
#macro PAREN_SUM (1 + 2)
</code></pre>
<p>The test goes in any object's Create event.</p>
<pre><code class="language-gml">show_debug_message(BARE_SUM * 3);
show_debug_message(PAREN_SUM * 3);
</code></pre>
<p>It printed 7, then 9. A macro is pasted in as text, so <code>BARE_SUM * 3</code> turns into <code>1 + 2 * 3</code>. Wrap any derived macro in parentheses.</p>
<p>Defining the same macro name twice stops the build. The error reads something like this:</p>
<pre><code class="language-plaintext">macro WALK_SPEED is already defined
</code></pre>
<p>Macros can also be overridden for one build configuration. Juju Adams wrote a short note on that, <a href="https://github.com/JujuAdams/ThoughtsOnGameMaker/blob/main/technique-4-config-macros.md">Technique 4: Config Macros</a>, and warns that edits made while in a non-default configuration apply only to that configuration. I haven't used overrides on this project, and his warning is the reason I'd be careful.</p>
<h2>A Starter File</h2>
<p>A short starter. Put the macros in a script asset, use the names from your objects, and tune the numbers here when playtest week comes.</p>
<pre><code class="language-gml">// Every number that might change during testing lives here.  Code uses the name, never the number.
// Speeds are pixels per step.

// Movement
#macro PLAYER_SPEED 4
#macro PLAYER_JUMP 10
#macro PLAYER_FALL_CAP (PLAYER_JUMP * 3)	// follows the jump.  keep the parentheses

// Health
#macro PLAYER_MAX_HP 20						// the starting value.  current hp is a variable

// Testing
#macro DEV_CHECKS true						// false for a release build
</code></pre>
<p>Then in a Create event:</p>
<pre><code class="language-gml">hp = PLAYER_MAX_HP;
</code></pre>
<p>And a Step event:</p>
<pre><code class="language-gml">x += PLAYER_SPEED * (keyboard_check(vk_right) - keyboard_check(vk_left));
if (DEV_CHECKS) show_debug_message("hp " + string(hp));
</code></pre>
<p><code>PLAYER_FALL_CAP</code> follows <code>PLAYER_JUMP</code> on its own. <code>DEV_CHECKS</code> is a switch you read in your own debug code and turn off for a release. The two events snippets go in your player object or whatever it is that's moving.</p>
<h2>Closing</h2>
<p>If you take one thing from this, decide early which numbers will change during testing, give them names, and keep them in one place. The rest is details, and I've listed the ones that bit me.</p>
]]></content:encoded></item></channel></rss>