   Handling enemy events in a shmup using lists
  Hey all.I'm my shmup project, I've gotten a basic event handler in place that basically spawns enemies after so much time passes.  It defines their start position, move speed, etc.What I'm looking to do next is how to actually handle what the enemies do.  For these type of games, they generally will enter the area, move around in some manner and fire shots at certain intervals.  The movements and shots fired can vary among any enemy, so it almost seems likely that every enemy will have its own list of events to use.An example could be:  Enemy enters at position (-16,200), moves right at a speed of 2 for 1 second, stops for 0.25 seconds, shoots something, moves up at a speed of 2 and keeps doing so until it leaves the play area or is killed...The approach I was thinking was for enemies to maybe read off a pointer to another list that has the specific movements and shots.  This way I could re-use movements if I wanted a party of enemies to have the same kind of behavior.  What I guess I'd need in this case is for every enemy to have an iterator for that list...Another thing though would be the bullet patterns.  These, perhaps, would also need to go into some list?It just seems there's quite a bit of considerations for all this.  Thoughts appreciated, thanks.   
  I seem to answer alot of these questions.  Here's what I did.Each enemy has a Action member function.  This Action member function would make the enemy do certain things.  the default action for all enemies does nothing but continues to move the enemy along it's present course and check it's weapons for firing.  Specific Actions would change the enemies direction/speed depending on it's location, the time it's been on screen, the location of yous ship, etc.For example, I had a giant Asteroid which would come on the screen and bounce around on the screen.  it would move until it hit the screen boundaries.  Once it was destroyed, it would spawn multiple little asteroids which would also bounce on the screen.Each Enemy has a particular Weapon type (or none) which has a firing rate and bullet type associated with it.  So, each frame, in the enemies action function, it would check it's weapons and see if it needs to fire a new bullet.  If it does, the bullets get put on the BulletsOnScreen list, and each bullet has a specific action function to denote how it acts.  Default bullets would just continue on it's current speed/direction.  For example, I have a homing type "bullet" which would "lazily" turn towards your ship (ie, every few seconds, turn 45 degrees towards your ship), and then explode if it doesn't hit anything after a longer period.Basically, you just need to associate action functions with enemies and bullets.  A more through implementation would be to use a scripting language to control the enemies and bullets, but that takes a little more to implement.Edit:  here's what the external files I read to define my enemies and weapons.# The Enemy attributes must be in this order!# Name:Enemy Name# Frames:Number of animation Frames# Clips:Clip filenames of frames in order with space between# if (frames != 0) time between changing frames # Starting X and Y Speed with space# Strength: Enemy Strength# Flags: looks in alpha.h for flags# Weapons: number of weapons, and if not 0 then...# WeaponType: Weapon Type Numbers (found in defines in alpha.h) with space# LocationXY: Starting location of enemy# Direction: Starting direction of enemy (0 = pointing left) Not Required!#Order: Left, Up, Right, Down, UpLeft, UpRight, DownRight, DownLeft# Note: Size, pFunc, and ulTimeOn don't have to be set# make sure the strings have no space between# Clips:enemy1.nif,enemy2.nifName:OrbFrames: 2Clips:orb1.bmp,orb2.bmpFrameTime: 300 300SpeedXY: -201 0Strength: 5Flags: 0Weapons: 0WeaponTypes: 0LocationXY: 640 50Direction: 0# Satellite; use on black background levels (Space)Name:SatelliteFrames: 10Clips:Sat1.bmp,Sat2.bmp,Sat3.bmp,Sat4.bmp,Sat5.bmp,Sat6.bmp,Sat7.bmp,Sat8.bmp,Sat9.bmp,Sat10.bmpFrameTime: 45 45 45 45 45 45 45 45 45 45 SpeedXY: -300 0Strength: 85Flags: 0Weapons: 0WeaponTypes: 0LocationXY: 640 50Direction: 0# Special Ship so set flag to 2 if only upgradeName:SpecialFrames: 1Clips:SpecialEnemy.bmpFrameTime: 0SpeedXY: -134 134Strength: 12Flags: 2Weapons: 0WeaponTypes: 0LocationXY: 640 400# Upgrade object for upgrading weaponsName:UpgradeFrames: 1Clips:WeapUpgrade.bmpFrameTime: 0SpeedXY: 0 -134Strength: -1Flags: 2Weapons: 0WeaponTypes: 0LocationXY: 0 0# NewOption object for upgrading weapons (flag 8 = NEW_OPTION)Name:NewOptionFrames: 4Clips:option1.bmp,option2.bmp,option3.bmp,option4.bmpFrameTime: 45 45 45 45SpeedXY: -134 0Strength: -1Flags: 8Weapons: 0WeaponTypes: 0LocationXY: 0 0# Homing Weapon object for Homing Missile (flag 65536 + 4 = WEAPON_UPGRADE)Name:HomingFrames: 1Clips:HomingObject.bmpFrameTime: 0SpeedXY: -134 0Strength: -1Flags: 65540Weapons: 0WeaponTypes: 0LocationXY: 0 0# Plasma object for Plasma Blaster (flag 131072 + 4 = WEAPON_UPGRADE)Name:PlasmaFrames: 1Clips:plasmaobj.bmpFrameTime: 0SpeedXY: -134 0Strength: -1Flags: 131076Weapons: 0WeaponTypes: 0LocationXY: 0 0# EMP object for Bomb (flag 262144 + 4 = WEAPON_UPGRADE)Name:EMPFrames: 1Clips:emp.bmpFrameTime: 0SpeedXY: -201 0Strength: -1Flags: 262148Weapons: 0WeaponTypes: 0LocationXY: 0 0# Fighter enemy (it looks like a fighter plane or helicopter ;)Name:FighterFrames: 4Clips:helicopter1.bmp,helicopter2.bmp,helicopter3.bmp,helicopter4.bmpFrameTime: 30 30 30 30SpeedXY: -268 0Strength: 32Flags: 0Weapons: 1WeaponTypes: 6Refire: 3000LocationXY: 640 120# Skimmer enemyName:SkimmerFrames: 1Clips:skimmer.bmpFrameTime: 0SpeedXY: -268 0Strength: 19Flags: 0Weapons: 1WeaponTypes: 0Refire: 1200LocationXY: 640 450# GunTower (it moves along slowly, only shooting bullets)# Clips:expe1.nifName:GunTowerFrames: 1Clips:guntower.bmpFrameTime: 0SpeedXY: -134 0Strength: 36Flags: 0Weapons: 1WeaponTypes: 0Refire: 2600LocationXY: 640 10# EndBoss1# flags = 128 (2^BOSS)# no refire; setup in functionName:EndBoss1Weapons: 7WeaponTypes:0,0,0,0,0,4,4Frames: 1Clips:boss.bmpFrameTime: 0SpeedXY: -536 0Strength: 1200Flags: 128LocationXY: 640 10# BigRock (big rock, bounces around on screen, moving left slowly)Name:BigRockFrames: 4Clips:bigrock1.bmp,bigrock2.bmp,bigrock3.bmp,bigrock4.bmpFrameTime: 400 400 400 400SpeedXY: -134 0Strength: 120Flags: 0Weapons: 0WeaponTypes: 0LocationXY: 640 24# LilRock (little rock, bounces around on screen, moving left quicker)# NOTE: location doesn't matter (this spawns from BigRock)Name:LilRockFrames: 4Clips:lilrock1.bmp,lilrock2.bmp,lilrock3.bmp,lilrock4.bmpFrameTime: 300 300 300 300SpeedXY: -201 0Strength: 72Flags: 0Weapons: 0WeaponTypes: 0LocationXY: 640 24# Falcon (millenum Falcon! Frames are tricky. Not animated, depends on Direction)Name:FalconFrames: 4Clips:FalconU.bmp,FalconL.bmp,FalconD.bmp,FalconR.bmpFrameTime: 0 0 0 0SpeedXY: 201 0Strength: 56Flags: 0Weapons: 1WeaponTypes: 0Refire: 3000LocationXY: -15 420Direction: 0# Spread Weapon: Spread Gun (flag (2^19)524288 + 4 = WEAPON_UPGRADE)Name:SpreadFrames: 1Clips:SpreadObject.bmpFrameTime: 0SpeedXY: -134 0Strength: -1Flags: 524292Weapons: 0WeaponTypes: 0LocationXY: 0 0# Shooter: Shoots bullets all aroundName:ShooterWeapons: 8WeaponTypes:0,0,0,0,0,0,0,0Frames: 1Clips:shooter.bmpFrameTime: 0SpeedXY: 134 -134Strength: 80Flags: 0LocationXY: -10 100# Small Bat, flies straight, then dives towards playerName:BatFrames: 8Clips:bat1.bmp,bat2.bmp,bat3.bmp,bat4.bmp,bat5.bmp,bat6.bmp,bat7.bmp,bat8.bmpFrameTime: 180 30 30 30 30 30 30 30SpeedXY: -200 0Strength: 60Flags: 0Weapons: 0WeaponTypes: 0LocationXY: 640 50Direction: 0# end guy, pretty tough!Name:BigBatFrames: 8Clips:bigbat1.bmp,bigbat2.bmp,bigbat3.bmp,bigbat4.bmp,bigbat5.bmp,bigbat6.bmp,bigbat7.bmp,bigbat8.bmpFrameTime: 300 100 100 100 100 100 100 100SpeedXY: -40 0Strength: 3000Flags: 0Weapons: 7WeaponTypes:0,0,0,0,0,0,0LocationXY: 640 100Direction: 0# Weapons file set em up, and put em down# Look for the Bullet Type in alpha.h# Function is dependent on the type# Pea Shooter using the Pea BulletType: 0Refire: 150Sound: 0SpeedXY: 1072 0Strength: 5Flags: 0Frames: 1Clips:Ebullet1.bmpFrameTime: 0# Homing Missile (type = 1, Flags = 1 (EXTRA_WEAPON), Function = 1 (HOMING_FUNC))Type: 1Refire: 1200Sound: 1SpeedXY: 402 0Strength: 20Flags: 1Frames: 2Clips:homing1.bmp,homing2.bmpFrameTime: 30 30# Plasma Gun (type = 2, Flags = 0, Sound = 7)Type: 2Refire: 260Sound: 7SpeedXY: 804 0Strength: 15Flags: 0Frames: 6Clips:plasma1.bmp,plasma2.bmp,plasma3.bmp,plasma4.bmp,plasma5.bmp,plasma6.bmpFrameTime: 30 30 30 30 30 30# Bomb, not really a weapon (type = 3, Flags = 0 (setup flags later), Sound = 10)Type: 3Refire: 0Sound: 10SpeedXY: 0 0Strength: 20Flags: 0Frames: 4Clips:bomb1.bmp,bomb2.bmp,bomb3.bmp,bomb4.bmpFrameTime: 45 45 45 45# Big Bullet (type = 3, Flags = 0, Sound = 19)Type: 4Refire: 2500Sound: 19SpeedXY: -335 -134Strength: 15Flags: 0Frames: 2Clips:bigbul1.bmp,bigbul2.bmpFrameTime: 30 30# Spread Gun (type = 5, Flags = 0, Sound = 25)Type: 5Refire: 300Sound: 25SpeedXY: 670 0Strength: 15Flags: 0Frames: 4Clips:spread1.bmp,spread2.bmp,spread3.bmp,spread4.bmpFrameTime: 90 180 240 2000 # Slo-Homing Missile (type = 6, Flags = 1 (EXTRA_WEAPON), Sound = 1)# Frames depend on Direction of BulletType: 6Refire: 3500Sound: 1SpeedXY: -201 0Strength: 10Flags: 1Frames: 8Clips:SloHomingL.bmp,SloHomingU.bmp,SloHomingR.bmp,SloHomingD.bmp,SloHomingUL.bmp,SloHomingUR.bmp,SloHomingDR.bmp,SloHomingDL.bmpFrameTime: 0 0 0 0 0 0 0 0