#include #include #include "fw.h" #include "pad.h" #include "Dogfight.h" #include "inits.h" void init ( void ) { // Lets talk layers : // Shots from player 1 = Layer 1 // Shots from player 2 = Layer 2 // AA Fire = Layer 3 // Ground = Layer 4 // Hangers = Layer 5 // Player 1 = Layer 6 // Player 2 = Layer 7 int CurrentPlayer; int CurrentShot; int CurrentAAFire; int CurrentSmoke; int WallYPos; int HangerYPos; int CurrentGround; int GroundWidth; int NextGroundXPos; int GroundYPos; int PlaneStartY; fwActorReset (); fwAnimateReset (); fwDirectSetBackGround ( 0, 0, 128 ); // Load up our costumes. PlaneCostume = fwCostumeAdd ( TEXTURE_PLANE, 2, 1 ); ShotCostume = fwCostumeAdd ( TEXTURE_SHOT, 1, 1 ); AAFireCostume = fwCostumeAdd ( TEXTURE_AAFIRE, 2, 3 ); GroundCostume = fwCostumeAdd ( TEXTURE_GROUND, 1, 1 ); HangerCostume = fwCostumeAdd ( TEXTURE_HANGER, 1, 2 ); WallCostume = fwCostumeAdd ( TEXTURE_WALL, 1, 1 ); ScoreCostume = fwCostumeAdd ( TEXTURE_SCORE, 2, 5 ); // For now we shall us the aafire costume as our smoke cloud costume SmokeCostume = AAFireCostume; // Actors used to display the curret score ScoreActor[0] = fwActorAdd ( ScoreCostume ); ScoreActor[1] = fwActorAdd ( ScoreCostume ); fwActorSetOnStage ( ScoreActor[0], OFF_STAGE ); fwActorSetOnStage ( ScoreActor[1], OFF_STAGE ); // Set up the screen details GroundActor[0] = fwActorAdd ( GroundCostume ); fwActorSetLayer( GroundActor[0], STAGE_LAYER_4 ); fwActorSetOnStage ( GroundActor[0], ON_STAGE ); GroundYPos = ( fwDirectScreenHeight() - ( fwActorGetPixelHeight ( GroundActor[0] ) >> 1 ) ) << STAGE_SHIFT; fwActorPos ( GroundActor[0], ( fwActorGetPixelWidth( GroundActor[0] ) >> 1 ) << STAGE_SHIFT, GroundYPos ); CurrentGround = 0; GroundWidth = fwActorGetPixelWidth ( GroundActor[0] ) << STAGE_SHIFT; NextGroundXPos = GroundWidth; while ( NextGroundXPos < ( fwDirectScreenWidth() << STAGE_SHIFT ) ) { CurrentGround++; GroundActor[CurrentGround] = fwActorAdd ( GroundCostume ); fwActorPos ( GroundActor[CurrentGround], NextGroundXPos+ ( GroundWidth >> 1 ), GroundYPos ); fwActorSetLayer( GroundActor[CurrentGround], STAGE_LAYER_4 ); NextGroundXPos+=GroundWidth; } WallActor = fwActorAdd ( WallCostume ); fwActorSetLayer( WallActor, STAGE_LAYER_4 ); fwActorSetOnStage ( WallActor, ON_STAGE ); WallYPos = ( ( fwDirectScreenHeight() - fwActorGetPixelHeight ( GroundActor[0] ) ) - ( fwActorGetPixelHeight ( WallActor ) >> 1 ) ) << STAGE_SHIFT; fwActorPos ( WallActor, fwDirectScreenWidth() << (STAGE_SHIFT-1), WallYPos ); HangerActor[0] = fwActorAdd ( HangerCostume ); fwActorSetLayer( HangerActor[0], STAGE_LAYER_5 ); HangerActor[1] = fwActorAdd ( HangerCostume+1 ); fwActorSetLayer( HangerActor[1], STAGE_LAYER_5 ); HangerYPos = ( ( fwDirectScreenHeight() - fwActorGetPixelHeight ( GroundActor[0] ) ) - ( fwActorGetPixelHeight ( HangerActor[0] ) >> 1 ) ) << STAGE_SHIFT; fwActorPos ( HangerActor[0], ( fwActorGetPixelWidth( HangerActor[0] ) >> 1 ) << (STAGE_SHIFT), HangerYPos ); fwActorPos ( HangerActor[1], ( fwDirectScreenWidth() - ( fwActorGetPixelWidth( HangerActor[1] ) >> 1 ) ) << (STAGE_SHIFT), HangerYPos ); // initialise the animations // The planes and shots will be wraping round the stage // The parameters for the animations are ( To save on looking up the fwanimat.h file ): // 1. Kind of animation. In this case its repeat so the object will wrap around on the screen // 2. How many times to repeat. -1 indicates that the animation is set to repeat indefinately // 3. What is the initial value of the animation. ( Start position of actor ) // 4. Minimum value allowed. // 5. Maximum value allowed // 6. Initial change value for the animation. 0 = stationary. The main game loop will modify // the change values to move the actors about. // 7. Pasue time. Length of frames to wait between changing animation value. Set to zero as // in our case we want to apply the animation for every frame. PlaneStartY = ( ( fwDirectScreenHeight() - fwActorGetPixelHeight ( GroundActor[0] ) ) - ( fwActorGetPixelHeight ( PlaneActor[0] ) >> 1 ) ); XPlaneAnim[0] = fwAnimateAdd ( ANIMATE_REPEAT, -1, ( ( fwActorGetPixelWidth(PlaneActor[0] ) >>1 )<> 1 ) ) << STAGE_SHIFT, 0, fwDirectScreenWidth()<