#ifndef _H_BiplaneMover #define _H_BiplaneMover #include enum { NUM_BIPLANE_BITMAPS = 16, // number of bitmaps per player (16 red, 16 blue) BIPLANE_HEIGHT = 16, // height of a biplane bounding square, in pixels MAX_SPEED_256THS = 5 * 256, // in 256ths of a pixel MIN_SPEED_256THS = 900, ACCELERATION_256THS = 6, // about 0.025 * 256; see BiplaneMover_computeGravity() re: gravity // Directions that a "direction functor" can decide to take. // See BiplaneDirectionFunctor. // DIR_FORWARD = 0, DIR_CLIMB = 1, DIR_DIVE = 2, }; // Must return a direction to be taken by the biplane, i.e., // one of the DIR_* values above. // typedef byte (*BiplaneDirectionFunctor)(void); typedef struct BiplaneMover { struct Sprite *biplane; sword speed; // in 256ths of a pixel byte numFramesBeforeSpawn; BOOL hasStarted; // has launched (is not waiting for take off) BOOL isStalled; const struct PreShiftedBitmap **biplaneBitmapArray; byte climbIncr; // to be added to biplane->sprite to make plane climb up byte diveIncr; // ditto, for diving BiplaneDirectionFunctor directionFunctor; } BiplaneMover; void BiplaneMover_init(BiplaneMover *self, struct Sprite *biplane, const struct PreShiftedBitmap *biplaneBitmapArray[], byte climbIncr, byte diveIncr, BiplaneDirectionFunctor directionFunctor); // Returns TRUE if the plane has crashed and an explosion must be started // at the position of self->biplane. // In that case, the biplane has already been marked as inactive. // BOOL BiplaneMover_move(BiplaneMover *self); #endif /* _H_BiplaneMover */