home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / SpriteWorld 2.2 / SpriteWorld Examples / Split-Screen Scrolling / Sprite Stuff.h < prev   
Encoding:
Text File  |  1998-04-05  |  3.0 KB  |  112 lines  |  [TEXT/CWIE]

  1. ///--------------------------------------------------------------------------------------
  2. // Sprite data structures
  3. ///--------------------------------------------------------------------------------------
  4.  
  5. typedef struct TankStruct
  6. {
  7.     SpriteRec        tankSprite;
  8.     Rect            insetRect;            // Inset when performing Tile collision detection
  9.     short            tankType;            // kPlayer1 or kPlayer2
  10.     short            numBulletsOnScreen;    // How many bullets this tank has on the screen
  11.     short            nextShotDelay;        // Delay before next shot
  12.     short            gunType;            // kNormalGun, kMachineGun, kSpreadGun, etc.
  13.     short            damage;                // Amount of damage to this tank
  14.     Boolean            canShoot;            // Set to true when user releases shoot key
  15.     Boolean            wasHit;                // Tells our MoveProc to undo the flash to white when hit
  16. } TankStruct, *TankStructPtr;
  17.  
  18.  
  19. typedef struct BulletStruct
  20. {
  21.     SpriteRec        bulletSprite;
  22.     TankStructPtr    parentStructP;        // pointer to the parent tank for this bullet
  23.     short            numMovesLeft;        // Number of moves before the bullet disappears
  24. } BulletStruct, *BulletStructPtr;
  25.  
  26.  
  27.  
  28. ///--------------------------------------------------------------------------------------
  29. // Definitions
  30. ///--------------------------------------------------------------------------------------
  31.  
  32.  
  33. #define kTankSpeed                8
  34. #define kMaximumDamage            50
  35.  
  36. #define kBulletSpeed            20
  37. #define kMaxNumBullets            2
  38. #define kNextShotDelay            2
  39.  
  40. #define kTankHeight                50
  41. #define kTankWidth                50
  42. #define kHalfTankHeight            25
  43. #define kHalfTankWidth            25
  44. #define kBulletSize                8
  45. #define kHalfBulletSize            4
  46.  
  47. #define kPlayer1                0
  48. #define kPlayer2                1
  49.  
  50.  
  51. typedef enum
  52. {
  53.     kNormalGun = 0,
  54.     kMachineGun,
  55.     kBigBulletGun
  56. } GunType;
  57.  
  58.  
  59. typedef enum
  60. {
  61.     kTankUpFrameIndex = 0,
  62.     kTankUpRightFrameIndex,
  63.     kTankRightFrameIndex,
  64.     kTankDownRightFrameIndex,
  65.     kTankDownFrameIndex,
  66.     kTankDownLeftFrameIndex,
  67.     kTankLeftFrameIndex,
  68.     kTankUpLeftFrameIndex,
  69.     kFirstTankBlowUpFrame,
  70.     kLastTankBlowUpFrame = kFirstTankBlowUpFrame + 9,
  71.     kNoDirection
  72. } TankDirectionType;
  73.  
  74.  
  75. ///--------------------------------------------------------------------------------------
  76. // Function Prototypes
  77. ///--------------------------------------------------------------------------------------
  78.  
  79. void        LoadSprites( void );
  80. void        DisposeSprites( void );
  81. void        SetUpSprite(SpritePtr mySpriteP, OSErr err);
  82.  
  83. SpritePtr    NewTankSprite( short tankType );
  84. SpritePtr    NewBulletSprite( void );
  85. SpritePtr    NewPowerUpSprite( GunType gunType );
  86.  
  87. SW_FUNC void TankSpriteMoveProc(SpritePtr tankSpriteP);
  88. SW_FUNC void BulletSpriteMoveProc(SpritePtr srcSpriteP);
  89. SW_FUNC void DeadTankFrameProc(SpritePtr tankSpriteP, FramePtr curFrameP, long *frameIndex);
  90.  
  91. void    ShootBullet(SpritePtr tankSpriteP);
  92.  
  93. SW_FUNC void BulletSpriteCollideProc(
  94.     SpritePtr    bulletSpriteP,
  95.     SpritePtr    tankSpriteP,
  96.     Rect*        sectRect);
  97.  
  98. SW_FUNC void PowerUpCollideProc(
  99.     SpritePtr    powerUpSpriteP,
  100.     SpritePtr    tankSpriteP,
  101.     Rect*        sectRect);
  102.  
  103. void    DamageTank( SpritePtr tankSpriteP, short damageAmount );
  104.  
  105. SW_FUNC void TankHitDrawProc(
  106.     FramePtr srcFrameP,
  107.     FramePtr dstFrameP,
  108.     Rect* srcRect,
  109.     Rect* dstRect);
  110.  
  111.  
  112.