class formation
The formation
class manage an array of enemy
objects, moving them in preset direction, acting like a formation of invaders.
Before constructing a formation
object, user should build a st_formation_param
structure containing valid pointers to st_item
and st_formation_move arrays.
Examples for how to do this in create_invaders_formation()
and create_galaxian_formation()
methods.
Each st_item contains an enemy object pointer and additional info that is used by formation
object.
(e.g. item state)
Each st_formation_move, defines the direction of x,y movement for the formation
and times field that tells how many times to repeat this direction.
Once committed times movements in certain direction, the int_to_next_move field tells the formation
what is the next move. Thus a loop of moves can be done.
The protected member attack_ok helps to co-ordinate a "halt attack" state for all object derived from formation
class (inv_formation
, gal_formation
).
Check out the base.h
file to learn more about available functions for this class. object.
For each frame user have to call the remove()
, action()
and draw()
method.