💥 Your Ball Asplode

BLaTTiX - Mon, 24 May 2021 09:30:21 GMT

Explosion animations are in.

Thanks to Flecs this was surprisingly simple to implement, given that there was no existing animation system. I just created a new Animated component like this:

typedef struct Animated
{
  int width;
  int height;
  int frames;
  double duration;
  double time;
} Animated;

The existing Render system uses this component, if present, to determine the source clip rectangle on the texture being rendered. Just a few lines of code. And the existing Collision system was updated to despawn balls and bullets and spawn a new explosion entity when a collision between them occurs.

Simples!