(click to interact)(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.
(click to interact)(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.
Partially related to an earlier blog post about minifying JSON (which I had just updated), but adressing a different problem - sometimes, rather than trying to make your JSON more compact (and, consequently, less readable), you may want to make it more readable - be that for your own debugging purposes, or not to scare players away from files that they are allowed to edit.
Take Nuclear Throne, for example. The save file is a big nested JSON structure, and, needless to say, you aren't getting around passing it through an external JSON beautifier if you want to be able to make sense of it:
With a bit of string processing, however, you can have it printed out nicely readable:
This post is about implementing custom timelines in GameMaker.
Admittedly, timelines remain to be one of the more dated features of the software, designed for a specific purpose and kept in their original form for compatibility.
Time to time you'll see someone stopping by on forums to write a big rant about how these are a mess, do not do what they expect them to do, and should be redesigned immediately.
People will usually also argue that doing these things by yourself is too hard.
Since it is far easier than people claim, I decided to write a post about this.
This is a small post about a method for figuring out collision_line's "contact point" in GameMaker - in other words, obtaining not just whether there's something on the way, but also the nearest point on the nearest matching entity.
Most commonly asked about for "hitscan" weapons and laser-sights, but has many uses.