/****************** X-Wing Animation ScoTT Campbell 27/1/99 **************/ #include "../headers/shipanim.h" #define NULL_SHIP_ANIMATION ((void*)0) ship_animation_type* CreateShipAnimation() { ship_animation_type* shipAnim; shipAnim = (ship_animation_type*)malloc(sizeof(ship_animation_type)); if(shipAnim == NULL_SHIP_ANIMATION) return NULL_SHIP_ANIMATION; else return shipAnim; }/* CreateShipAnimation */ int DestroyShipAnimation(ship_animation_type* shipAnim) { if(shipAnim != NULL_SHIP_ANIMATION) free((void*)shipAnim); else return 1; return 0; }/* DestroyShipAnimation */ void InitialiseShipAnimation(ship_animation_type* shipAnim, int totalFrames, unsigned long int startAddress, unsigned long int imageSize, int speed) { int i; unsigned long int nextAddress = startAddress; for(i=0; ishipSpritesArray[i], nextAddress, 0, 0); nextAddress += imageSize; } InitialiseSpriteAnimation(&shipAnim->animation, shipAnim->shipSpritesArray, totalFrames, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, NON_CONTINUOUS); shipAnim->shipSpeed = speed; }/* InitialiseShipAnimation */ void UpdateShipAnimation(ship_animation_type* shipAnim, unsigned long int padValue) { static int smoother = 0; if(smoother) { if(padValue & PAD1_LEFT) UpdateCurrentSprite(&shipAnim->animation, -1); if(padValue & PAD1_RIGHT) UpdateCurrentSprite(&shipAnim->animation, 1); if(!((padValue & PAD1_LEFT) | (padValue & PAD1_RIGHT))) { if(shipAnim->animation.currentSprite < 4) UpdateCurrentSprite(&shipAnim->animation, 1); else if(shipAnim->animation.currentSprite > 4) UpdateCurrentSprite(&shipAnim->animation, -1); } smoother--; } else smoother++; MoveSpriteAnimation(&shipAnim->animation, shipAnim->animation.currentSprite - 4, 0); if(padValue & PAD1_DOWN) MoveSpriteAnimation(&shipAnim->animation, 0, shipAnim->shipSpeed); if(padValue & PAD1_UP) MoveSpriteAnimation(&shipAnim->animation, 0, -shipAnim->shipSpeed); }/* UpdateShipAnimation */ void DrawShipAnimation(ship_animation_type* shipAnim, GsOT* otPtr, int priority) { DrawSpriteAnimation(&shipAnim->animation, otPtr, priority); }/* DrawShipAnimation */