Simple intersection checking between rotated rectangles and circles/points

(click to interact)Intersection checking between rotated rectangle and point/circle
(mouseover/click to play GIF) (click and drag to adjust rectangle size/position/rotation; distance to a circle is shown)

Suppose you have a rotated rectangle and a basic shape that rotation doesn't matter for (such as a point, circle, or a line segment), and you want to check whether the two are intersecting - be that for collision handling, hit testing, or whatever else.

On a glance this might seem like a bother because things are rarely too simple with rotated rectangles, but in this case it isn't - because you can "unrotate" the rectangle.

This small post is about that.

Continue reading

2d pivot points explained

(click to interact)Explaining pivot points
(mouseover/click to play GIF) (spaceship graphic by Kenney)

Nowadays, most development tools provide ways of setting pivot/center point for imagery - that is, the relative point around which the image will rotate and usually be positioned relative to.

However, ability to define multiple pivot points per image remains relatively uncommon, despite being something that you want to have projectiles fire from a correct point of a sprite, display weapons/attachements at right relative points, or do anything else that demands relative offsets.

This small post is about that.

Continue reading

Converting key code to key name and vice-versa

(click to interact)Converting key code to key name and vice-versa
(mouseover/click to play GIF) Interactive demo (if JavaScript is enabled)

This is a small post about how to convert key codes to key names and/or convert key names to key codes. Comes with sample code for GameMaker and a generic version.

Mostly published because it covers majority of common and semi-common buttons.

Continue reading

GameMaker: Using external version control

Over time, I have witnessed a particular scenario a few too many times:

  1. A person demonstrates complete unwillingness to learn how to use version control, be that due to "lack of need" or delightful claims of their existing approaches (which most often turn out to be manual backups) being sufficient or even superior.
  2. A person loses days, weeks, or even months of work due to human error and/or hardware failure(s).
  3. Noticeably bitter about the situation, a person attempts to continue defending their position.

Having spent far too much time arguing with people and explaining how to use version control, I have decided to make a blog post that would cover a few things on the matter:

  • Explain the advantages of version control over "simpler" backups.
  • Explain (step-by-step) the basics of using a common combination for version control being BitBucket (service) + Git (software) + SourceTree (GUI client).

While this tutorial is oriented on GameMaker: Studio users, it can also be easily applied for other tools.

Continue reading

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

Top-down bouncing loot effects

GIF
In action

A little while ago, I was asked about what would be a good approach to creating an effect for a top-down game where coins would fly out of a smashed object. Not recalling any tutorials on the matter, I've made an example of this exact thing, and this is a post detailing everything related to such an effect.

Continue reading

Hosting HTML5 games on Google Drive

Hosting HTML5 games on Google Drive for free

Being able to quickly upload a HTML5 game to the web is important.

It's not just a more comfortable format for sharing, but sometimes a requirement, since games created with GameMaker: Studio, Construct 2, Haxe+OpenFL and many other tools may not necessarily fully function when launched locally due to browsers laying restrictions over local file access (meaning that sending a ZIP with game files may not quite work).

While it used to be possible to host HTML5 games on Dropbox for free (or, rather, it still is possible, but only if you have enabled the public folder before the late 2013, else it'll cost you some), you can still host HTML5 games freely on Google Drive.

And this article explains the process of hosting your games on Google Drive in detail.

Continue reading

Adding thousand separators

string_thousands

Often, games and applications may display numbers. Sometimes, large numbers. In some cases, numbers with so many digits that you aren't even sure about most suitable notation.

And that's where use of thousand separators is handy. Since delimiter symbols (normally commas) appear in fewer quantity than digits, they are easier to count, and user can tell the order of magnitude easier.

This post covers detail of doing that, both in algorithm and code.

Continue reading