Skip to content

Instantly share code, notes, and snippets.

@quephird
Last active August 29, 2015 14:12
Show Gist options
  • Save quephird/47344ec8059e78a29428 to your computer and use it in GitHub Desktop.
Save quephird/47344ec8059e78a29428 to your computer and use it in GitHub Desktop.
OK... so for my DoDonPascii game I can generate waves of baddies, each with different sprites
and attack patterns. But now, I want to be able to associate potential powerups with certain
waves of baddies. One of the common idioms/cliches in shmups is having to wait for the red
planes to come out; if you shoot them all then a powerup is dropped. If even one escapes,
the opportunity is gone and you have to wait for the next wave of red planes to come out.
Here are the rules that I think I want to try to enforce:
* The powerup is _only_ associated with a specific wave when comes out.
* The powerup _only_ becomes available when all of the baddies in that wave are destroyed.
* The powerup becomes immediately _unavailable_ when any of the baddies escapes.
* Powerup opportunities are not cumulative; if you shoot three in one wave and then two
in the next, you don't get the powerup. The first one is gone, and the second one you start from 0;
* There could be multiple powerups in play simultaneously since there could be multiple waves
on the screen simultaneously.
How do I actually do this? So far, I think I could do the following:
* Associate a powerup opportunity with a wave in the code that describes the levels of the game.
* When the powerup wave comes out, I can cons some sort of event to a list with the count of baddies
in that wave.
* As I shoot each enemy in that wave, I can decrement that count; If I've reached zero, then I
can spawn a powerup.
Here are the problems:
* If the wave passes and some enemies escape, I have an event sitting there in suspense.
How do I get rid of it?
* If I have multiple events, how do I know which enemies "belong" to which opportunity?
* If I need to associate enemies with opportunities, what data structure do I use? Do I
need to resort to ID's that are generated at runtime?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment