Created the Debris System

This was such an unholy struggle – the lengthdir_x/y(length, direction) functions in GameMaker should be straightforward to me, but they took an awfully long time to grok. Still, having enemies that exploded into debris clouds in roughly the same shape and angle that they were in their final moments was tremendously satisfying. Again, I wanted the system to be as universal and data-driven as I could make it; the system allows for manual control, but by default it looks at the type of enemy to determine the debris sprites, and the size and mass of the enemy to determine quantity.

The discussion at the end reminded me that early on, powerups could be shot and destroyed (to discourage spamming). As an alternative, I thought about having them change to a points-up bonus instead (so players could tactically forgo powerups to try for a higher score), but this proved to be a sufficient “feels-bad” for my testers that I scrapped it entirely.

2021-10-27 12:16 PM Last night and this morning, I built the debris system. Asteroids and Droids now eject a selection of particles based on the sprite size and falling in the rotated sprite footprint, which looks BOSS but was very, very difficult to do. After a lot of looking, I adapted code from this nice fellow, extending the draw potential over the entire sprite, rather than sticking to the corners. Here’s the code:

// Returns a random point on the given sprite as the array: [x, y]
function coords_on_sprite(_x, _y, _angle, _sprite_height, _sprite_width) {
  var xx = random_range(-(_sprite_width / 2), (_sprite_width / 2));
  var yy = random_range(-(_sprite_height / 2), (_sprite_height / 2));
  var dist = point_distance(0, 0, xx, yy);
  var dir = point_direction(0, 0, xx, yy);

  return [
    _x + lengthdir_x(dist, _angle + dir),
    _y + lengthdir_y(dist, _angle + dir)
  ];
}

I also fiddled with drops to make armoured asteroids leave capsules rather than straight powerups, treasure-chest-like. And, I turned on spawning powerups from capsules, as with dual-shots, it was too easy to kill their dropped powerups.

Now that a debris system is in place, I next want to spit out a smaller magnitude of debris when an enemy transitions from one damage state to the next.

Then, enemy bullets and shield interactions seems like a fun idea.

I also had thoughts about how I could do the waves: I can do an array of anonymous functions, with the functions containing the full script of a given wave. I’ll array_pop (or array_shift, but I need to implement it) the wave array, and the last element to be popped will end the game. Boop boop.