“Making a Godot game in GameMaker” breakdown


Click to watch the video on YouTube (or on Twitter, Reddit)

For this April Fools I made a small video showing me create and run a Godot project in GameMaker!

It's a good goof, but what if I told you that the video is not edited?

This is a post about how that had been accomplished.

Website

The video starts with me showing a "link Godot account" on YoYo Account website.

This had been accomplished by writing a small TamperMonkey userscript that uses MutationObserver to timely inject a bit of HTML when the related UI is about to pop up on screen.

"Godot project" button in GameMaker

Little known fact, GameMaker's IDE skinning engine is pretty advanced - you can even edit layout files to change nesting or order of components in the UI!

Here I have added a new icon for Godot and defined an extra button on the "new project" page that uses the "new GML project" ID (while the original button is left without an ID and does nothing when clicked).

Styling

Since Godot also has a degree of IDE skin customization (colors, fonts), I took this opportunity to adjust the colors and fonts to match those of GameMaker - this way the Godot windows "blend in" the GM UI.

Godot in GameMaker

Windows is a beautiful OS!

Did you know that you can use SetParent to embed a window into a completely unrelated window, and without having to ask for permission from either of two?

Some readers might recall that I have already visited this topic before, but this takes it a step further: if you combine the above with placing windows on negative (or otherwise out-of-parent) coordinates and borderless windows, you can seemingly embed a part of a window into another window.

And so I do! With help of a (poorly written) AutoIt script and an extra mouse button, the whole ordeal looks as following:

  • I prepare two Godot windows - one with the sample project already open, and one with the "samples browser".
  • Both windows are embedded into borderless windows (to clip them accordingly) and then into GMS2 IDE window at a high enough offset that they cannot be seen.

    They are also resized to fit the window size.

  • Await a key press so that clicking "Save" in "new project" file selector simultaneously clicks and moves in the Godot samples window.

    I conveniently cover the entire workspace (including the resource tree) so that you cannot see that the resource tree is expanded.

  • Await a key press so that clicking "3D Platformer Demo" in the samples window simultaneously clicks, hides the samples window, and replaces the project files with those of a prepared project (with replica resources added to it);

    Replacing the project files triggers a project reload as per GMS2 Preferences checkbox.

  • Await a key press to simultaneously double-click the "stage" in the resource tree and show the Godot scene editor over the GMS2 workspace area.

    I have chosen the "Sequence" resource type for the stage since it opens a new workspace tab but does not open any additional side panels.

  • Await a key press to simultaneously click the sidebar button to collapse the resource tree and to resize the Godot scene editor window to occupy that area.

    If you look at the video frame-by-frame, you can note that there's a few-frame desync with this as the Godot window resizes (covering the resource tree) but the resource tree had not collapsed yet.

  • Await a key press to send an F5 key press to Godot window and click "Run" button on the GameMaker in quick succession, making it seem that the Godot game ran as result of clicking that button.

    As to why you don't see a GameMaker game running too - well, that's because I have removed the default room from the project and the "the project needs at least 1 room to run" error box is covered by the embedded Godot window.

    For the subsequent run, I just press F5 without interacting with the toolbar.

Technical challenges

By default, clicking on an embedded window would take the focus away from GameMaker window, and title bar color together at that.

I have attempted to fix this via WS_EX_NOACTIVATE, but found that, to any or no surprise, a window with no focus does not accept keyboard input, meaning that I couldn't have the Godot window run the game without manually sending a mouse click event to hit the technically-invisible button.

Since this wasn't intended to be particularly high-effort, I have simply switched Windows to not apply theme color to title bar and moved the window slightly out-of-capture-area so that changes to title bar text color could not be seen.


And that's all!

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.