Version 2023.1: Easy Collisions, Crisper Fonts And New Audio Functionality


Version 2023.1: Easy Collisions, Crisper Fonts And New Audio Functionality

GameMaker 2023.1 brings easy collisions with slopes, crisper fonts, a new audio effect and more.

Easy Collisions With Slopes

The new move_and_collide() function makes collisions easier for you, and supports slopes.

You tell it the distance you want to move horizontally and vertically, along with the object you want to avoid (like a wall). That’s all you need to get it working:

undefined
Moving Clyde with move_and_collide()


What you see above runs on this Step event code:

var _move_x = keyboard_check(vk_right) - keyboard_check(vk_left);
var _move_y = keyboard_check(vk_down) - keyboard_check(vk_up);

move_and_collide(_move_x * 4, _move_y * 4, obj_wall);

Or, the GML Visual equivalent:

undefined

The function has additional arguments and also returns an array of instances, which you can read about in the manual.

Crisper Runtime Fonts

Enable SDF rendering for your font using font_enable_sdf().

Now if you draw some text with that font and scale it up, say using draw_text_transformed(), it won’t appear pixelated:

undefined

Currently you can only enable SDF for fonts loaded at runtime (with font_add()). Support for fonts added through the IDE will be provided in a future release.

Static Struct For Functions

With GameMaker 2023.1, you can get the static struct of a function (constructor or not) using static_get(). This is the struct where the static variables of that function are stored.

What are static variables?

Any function in GML can have static variables, which are initialised once, and can be read and modified at any moment.

They’re especially useful for constructor functions. Static variables are shared among all structs created from a constructor, meaning those static variables are owned by the constructor.

Static Chain

When using constructor inheritance, static structs are linked together in a way to form a “static chain”. Each static struct links back to its parent’s static struct (which you can get with static_get()).

This chain is used in the new is_instanceof() function, which tells you whether a struct is an “instance of” a given constructor.

For example, if you create a struct from the item constructor, checking is_instanceof(that_struct, item) will return true.

If the item constructor has a potion child constructor, checking is_instanceof(potion_struct, item) will still return true, as a potion is an item. See the following example:

function item() constructor {}

function potion() : item() constructor {}

function enemy() constructor {}

var _potion = new potion();

show_debug_message(is_instanceof(_potion, potion)); // true (1)
show_debug_message(is_instanceof(_potion, item)); // true (1)
show_debug_message(is_instanceof(_potion, enemy)); // false (0)

If this sounds confusing, that's fine - read the manual page on static structs and you should have a better understanding.

Tremolo Audio Effect

The new tremolo audio effect controls a sound's volume using an oscillator – a signal that goes up and down.

Here’s an example:

Download this sample project

On that note, audio_effect_create() now has a new argument. You can give it a struct with details about the effect you’re creating, so you can customise it in the same call.

So when creating an audio effect, you can use this new argument to set it up, and as always, you can also modify it directly via the returned struct:

bitcrusher = audio_effect_create(AudioEffectType.Bitcrusher, {
    gain: 1.1, factor: 20, mix: 0.5
});
bitcrusher.resolution = 4;
bitcrusher.mix = 0.8;

There will be more audio effects added in future releases. Let us know which ones you’d prefer to have first in this forum thread.

New Audio Function

audio_play_sound_ext() is a new function that works entirely using a struct.

With this, you can play a sound, and customise it using a struct to change its gain, pitch, position, and more.

var _sound_params =
{
    sound: snd_shot,
    priority: 20,
    gain: 1.2,
    pitch: 2,
    position:
    {
        x: 100,
        y: 100,
        z: 20
    }
};
audio_play_sound_ext(_sound_params);

This will play the snd_shot sound with a 20% gain increase, twice the pitch and place it at (100, 100, 20) in 3D space.

More Additions

  • Previously you could only add bitmap sprites to texture groups. Now you can add Spine, SWF and those with “Separate Texture Page” enabled to any texture groups in your project.
  • There are three new array functions: array_get_index(), array_contains() and array_contains_ext()
  • In previous versions, the “base” runtime in the Runtime Modules dialog included tools for Windows, macOS and Ubuntu. Now “base” only includes tools for the platform you are using the IDE on, with the rest of the platforms still selectable separately, so you can save space by deselecting platforms you don’t build for.
  • You can now disable obfuscation of the HTML5 runner code in the HTML5 preferences. This will make it easier to read GameMaker’s engine code when debugging your game on HTML5.

Download GameMaker 2023.1 and start creating now.

Happy GameMaking!


Written by Gurpreet S. Matharoo

Lead Technical Writer at GameMaker, Gurpreet creates documentation and tutorials to make game making easier for you. He loves using the computer to bring new things to life, whether it's games, digital art, or Metal music.