Files
Brian Holman 7939132267 Import coco-planes 0.1.0 upstream source snapshot
Original author: Pierre Sarrazin. Preserve upstream GPLv3-or-later and file-specific notices.
Source: http://sarrazip.com/dev/coco-planes-0.1.0.tar.gz
Archive SHA-256: 29191e6ba225965caa637ee726e1189639dc7fcdf2b68310fb93fbffd56c9c52
2026-11-09 23:39:59 -07:00

61 lines
1.7 KiB
C

#ifndef _H_BiplaneMover
#define _H_BiplaneMover
#include <coco.h>
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 */