MouseLock & PointerLock for GameMaker

(click for web demo)

I made a small GameMaker: Studio extension that provides a unified API for "mouselock" between desktop and web (HTML5).

The way this works is by utilizing built-in mouse snapping functions on desktop targets, and using Pointer Lock API on HTML5. It bridges between the two, and you get simple functions like mouse_lock(), mouse_unlock(), and mouse_delta_x & mouse_delta_y for getting the mouse movement offset while mouse is locked.

So, if you ever wanted to make some web-based first-person shooters (or just games with mouselook) with GameMaker: Studio, now you can.

The extension is free and can be downloaded from or GameMaker: Marketplace.

Understanding isometric grids

Isometric grid coordinate conversion demo
A GIF of the interactive demo seen later in this post.

Questions about the algorithms related to isometric grids are not uncommon. In fact, they are a little more common than you could expect them to be, given the relative simplicity of things.

So I have decided to write a little blog post on the two things important here:

  1. Converting local isometric grid' coordinates to global screen-space coordinates
  2. Converting global/screen-space coordinates to isometric grid' local coordinates
Continue reading

GameMaker: Windows-specific functions for Studio

While working on one of recent projects, I've stumbled upon few common issues that many meet - even if you are only targeting Windows in GameMaker: Studio, you cannot access files outside the game's AppData directory (not even in program directory). Neither you can order system to open a file, meaning no external "readmes" to be easily hooked up with game, nor portable configuration files, and some other limitations.
So I took an evening and made a simplistic DLL library to bring equivalents to some functions (sleep, execute_shell, non-sandboxed I/O) back for Windows target. Function list is as following:

Continue reading

GameMaker: Click ‘n drag to pan view


Today I'm going to tell a bit about implementing "click and drag to scroll" type of effect in GameMaker. This particular thing is useful for strategy games (and normally bound to middle mouse button), applications (where visible area may exceed available window space), and various mobile games and applications (where visible area may be panned by tapping and dragging the finger).
Effect itself looks like this:

Continue reading

GameMaker: Window sliding effects

Window sliding example for GameMaker

This post is about creating window sliding effect such as seen in my old program called GMConveter. Program itself was a bit of joke actually, since at the moment of it's publication the only actual difference between GM80 and GM81 formats was a version byte in file header, which GMConverter would change, making files compatible again. Not too bad of functional part for something that was downloaded over 4 thousand times over course of two years, right?
Apart from inner simplicity, it also had nice visuals, including a nice window sliding effect used on start and end of program. And that's what this article is about.

Continue reading

GameMaker: Recursive folder copying

In some situations you may want to copy a folder from your GameMaker game. And it would seem trivial but not that easy. file_copy can only copy files, and folder functions only allow you to create, check, and search folders for files. However, given these standard functions, implementing a folder copying routine is fairly easy.
Idea used here is to find a list of files and folders via file_find_*, and then go through them, checking whether they are files or folders, copying or recursively calling recursively function script accordingly. Sure that poses a potential problem if you were to copy entire disc contents to other location, but you are probably not going to be doing that via GameMaker... right?

Attached example contains the function and brief demonstration of functionality (you have to input source/destination paths as text). Script source is located below download button.

Download GMK

Continue reading

GameMaker: Basic 3d bone animations

This example demonstrates how to create fairly basic bones for use in GameMaker 3d games fairly easily. Such can be used for character and environment animations, provided that they can be split in rotatable parts to some extent.


As you may know, GameMaker does not quite support vertex animations. That means that models have to be either composed on-fly (which is a slow method), or "baked" as a number per-frame models (which takes amounts of memory proportional to how smooth you want your animations look). Bone animations, on other hand, work fast (since only transformation calculations need to be done), and require small amounts of memory.


Idea of bone transformations is that you have so called bones, which can be attached to other bones, which makes them rotate together. That means, to find transformation matrix (position, rotation, and scale) of any given bone, you need to go through all of its "parent" bones, combining matrices. Normally this would be a slightly tricky task (especially if engine of choice does not have matrix operations built in), but, fortunately, GameMaker includes a set of functions to manipulate matrices (d3d_transform_).

Attached example includes a minimal system for linking bones together, drawing them, and a sort of procedural animation example.

Download GMK

GameMaker: Shadow casting in platformer games

This is a very old example of mine actually (creation timestamp says Sep 2010), which I've recently fixed & improved by request.
It demonstrates a simple algorithm to cast shadow from instance in platformer game. So when player jumps, shadow is displayed on ground below (realism!).
For the sake of simplicity and performance, shadows are checked against bounding boxes by default. Pixel-perfect checking is added as a separate condition, requiring affected objects to be children of obj_complex.
If you're interested in how this works behind-the-scenes, here's an illustration:

Outlined instances are ones used for finding top-most position below the player (which shadow will be cast onto). Red line is a number of point checks to indicate top-most point on objects with precise masks.
As another random visual tweak, there's a piece of code added to make shadow shrink as caster gets further from ground. A minimal touch, but these do stack.

Download GMK