#include "Controller.h" #include "BiplaneMover.h" #include "util.h" #include // Choose the delay (in frames) before this controller decides to // launch the plane. // static word Controller_chooseNumFramesBeforeLaunch(void) { return rnd(1 * 20, 10 * 20); } void Controller_init(Controller *self, byte controlType, BiplaneMover *mover, byte probeBit, byte testBit, byte joyButtonMask) { assert(mover); self->controlType = controlType; self->mover = mover; KeyState_init(&self->fireKeyState, probeBit, testBit); self->joyButtonMask = joyButtonMask; // Only used with AUTOMATIC_CONTROLLER: self->state = STATE_READY_FOR_TAKE_OFF; self->numFramesBeforeStateChange = Controller_chooseNumFramesBeforeLaunch(); } void Controller_onBiplaneExplosion(Controller *self) { // The plane has just started exploding. // Put it back to "ready for take off" state. // Choose the wait time before taking off. // self->state = STATE_READY_FOR_TAKE_OFF; self->numFramesBeforeStateChange = Controller_chooseNumFramesBeforeLaunch(); }