Slow Rush Studios logo,
    depicting an apprehensive-looking snail rushing forward

Slow Rush Studios

◂  Back in Motion
News index
Effecting Sound  ▸

Timing Animations

Contents

Last week I hinted that timing animations was a bit of a pain, but fear not!

This week we've got that all worked out, so enemies can play perfectly timed attack animations.

Matching Art and Gameplay

From last week, we know that animations in pixel art games are just sequences of images displayed really quickly.

But if you've got an animation of an archer shooting a bow, how do you know when the animation is at the point where the game should "spawn" (create) the actual arrow that's getting shot out of the bow?

And how do you know where that arrow is supposed to be spawned, relative to the archer?

What happens if you don't put any effort into syncing animations with the actual attacks: it looks terrible.

One answer is: you fiddle with the projectile's exact spawn time and spawn offset until things look okay - but there's a better way.

Animation Hotspots

We're already drawing each attack animation as a sequence of images.

And as we're drawing, it's pretty clear where & when each projectile is supposed to appear.

What if we just.. drew that information onto the animation images directly? 1

We can! We just say "hey game, when you see the bright pink (hot)spot, create the arrow there": 2

Frame by frame breakdown of archer attack animation showing the hotspot used for timing and arrow spawn location
When game loads an animation, it finds the pink hotspot and stores it as an attack location.

Now the game knows both the attack's timing (because the game knows when each frame of animation will be played) and the attack's location.

As a bonus, we can use this to solve other fiddly problems too - like positioning enemy eyes in the right place, or marking which bits of enemies (or players) can be hit by attacks.

Hotspot Tooling

Of course, we don't want to have those special hotspot pixels actually get shown, so I draw them in a special hidden layer.

And to make it easy to draw the right hotspots, I made a small extension: 3

Screenshot of Hotspot Palette Aseprite extension
My Aseprite extension enables easily picking from configured hotspot colours, and (not shown) sets up the hidden layer to draw the hotspots onto.

Under the hood, the extension saves information like pink is attack and blue is eyes inside the animated image itself. 4

Putting It All Together

Now our enemies' attacks are in sync with their animations:

Archer and Hound attacks. The Hound's melee attack covers a whole box, which is also determined from a hotspot.

The implementation is still very basic overall - for example, each animation can only have one attack hotspot. But I figure I can improve that when I need more complicated attack patterns.

In Other News

I redid the news listing of the Slow Rush website to show a featured animation beside each weekly update.

It's pretty cool: you can scroll from top to bottom to see the progress each week.

I also finally took care of some legal things, like setting up a company and getting a privacy policy in place. 5

Playable web build‎

I also made the website's layout a fair bit wider, so that this playable demo has a lot more space:

Press F1 for help, including to see keyboard/mouse controls. Mobile devices probably won't work! By playing you agree to our Privacy Policy.

1

I can't claim credit for this idea! I first saw it in an old cave-flyer game called Jetmen Revival that has you flying around ships and shooting bullets & rockets at a friend: it used hotspots in its ship designs for defining your thrust locations and where bullets should appear.

Noita also uses this approach, of course.

2

Technically I have the game calculate the bounding box of the hotspot pixels, because sometimes I want a box but other times I just want a single point (the center of the box).

3

My aseprite hotspot extension is published here if you want to use it.

4

As JSON-encoded data in the Sprite's userdata; my game reads the Aseprite file format directly so there's no export step needed.

Having the colors configurable per sprite also means that I can e.g. use bright pink as an actual colour in a sprite if I want to.

5

There isn't anything crazy in the privacy policy, but I did have it drafted broadly enough to allow me to collect things like gameplay analytics, gameplay recordings and crash log information in future - just because it's nice to know if anyone's actually playing the game demo, and to know where people are getting stuck, and it's especially nice to know if the game is crashing a whole bunch.

But if you read it and it makes you freak out for some reason then please shoot me an email about it.

◂  Back in Motion
News index
Effecting Sound  ▸