Grid-based spirals

Good for placing objects around a grid cell! Like this:

A spiral spanning a 9x9 square grid. Points are numbered and lines show the path.
(try a newer browser for an interactive demo!)(enable JavaScript for an interactive demo!)
(click to interact)
Click/tap to select point

You give the function a grid XY and it tells you where the next point should be to have it go in a spiral.

Continue reading

GameMaker: Radial health/progress bars

This is a post about turning this

into this:


(try a newer browser for an interactive demo!)(enable JavaScript for an interactive demo!)
(click to interact)
Click/drag to adjust %

Continue reading

CSS-only reveal/frame comparison generator

Earlier this year, I made an image reveal/frame comparison generator for use with cohost!.

With website set to close at the end of this year, I have updated the tool to output that's easier to use outside of cohost!.

The idea is that you supply two image URLs, tweak a few settings, and get something like this back:

An image of the ct.js mascot, a sort of a blue blob-cat with an innocent smile
The same image, but the cat now has two knives 👀
?
Template by YellowAfterlife.
Dragging might not work with touch!

(if you are on iOS, resize-dragging is not currently supported - tap here for an animated preview)
An image of the ct.js mascot, a sort of a blue blob-cat with an innocent smile

And this works without any JavaScript!

The generator is available online, and in this post I go over how it works and what else it can do.

Continue reading

GameMaker: draw_sprite_ext_skew

(click to interact) (mouseover/click to play GIF) Drag sliders and click things (if JS is enabled)

This post is about a slightly fancier version of draw_sprite_ext - maybe you want to apply skewing/shearing to the sprite, or scale it after rotating it, or use a 2d matrix transformation.

The built-in function isn't made for that, but, with a little bit of math and draw_sprite_pos, you can have a script for this.

Continue reading

GameMaker: Formatted date output

(click to interact)

This is a small post about a replica of the strftime function seen in PHP, C standard library, and a handful of other APIs. Such a function takes a date-time and prints it according to the given format string.

The script supports the common formats and those that mapped reasonably to GML functions.

Continue reading

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