home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-05 | 3.0 KB | 112 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // Sprite data structures
- ///--------------------------------------------------------------------------------------
-
- typedef struct TankStruct
- {
- SpriteRec tankSprite;
- Rect insetRect; // Inset when performing Tile collision detection
- short tankType; // kPlayer1 or kPlayer2
- short numBulletsOnScreen; // How many bullets this tank has on the screen
- short nextShotDelay; // Delay before next shot
- short gunType; // kNormalGun, kMachineGun, kSpreadGun, etc.
- short damage; // Amount of damage to this tank
- Boolean canShoot; // Set to true when user releases shoot key
- Boolean wasHit; // Tells our MoveProc to undo the flash to white when hit
- } TankStruct, *TankStructPtr;
-
-
- typedef struct BulletStruct
- {
- SpriteRec bulletSprite;
- TankStructPtr parentStructP; // pointer to the parent tank for this bullet
- short numMovesLeft; // Number of moves before the bullet disappears
- } BulletStruct, *BulletStructPtr;
-
-
-
- ///--------------------------------------------------------------------------------------
- // Definitions
- ///--------------------------------------------------------------------------------------
-
-
- #define kTankSpeed 8
- #define kMaximumDamage 50
-
- #define kBulletSpeed 20
- #define kMaxNumBullets 2
- #define kNextShotDelay 2
-
- #define kTankHeight 50
- #define kTankWidth 50
- #define kHalfTankHeight 25
- #define kHalfTankWidth 25
- #define kBulletSize 8
- #define kHalfBulletSize 4
-
- #define kPlayer1 0
- #define kPlayer2 1
-
-
- typedef enum
- {
- kNormalGun = 0,
- kMachineGun,
- kBigBulletGun
- } GunType;
-
-
- typedef enum
- {
- kTankUpFrameIndex = 0,
- kTankUpRightFrameIndex,
- kTankRightFrameIndex,
- kTankDownRightFrameIndex,
- kTankDownFrameIndex,
- kTankDownLeftFrameIndex,
- kTankLeftFrameIndex,
- kTankUpLeftFrameIndex,
- kFirstTankBlowUpFrame,
- kLastTankBlowUpFrame = kFirstTankBlowUpFrame + 9,
- kNoDirection
- } TankDirectionType;
-
-
- ///--------------------------------------------------------------------------------------
- // Function Prototypes
- ///--------------------------------------------------------------------------------------
-
- void LoadSprites( void );
- void DisposeSprites( void );
- void SetUpSprite(SpritePtr mySpriteP, OSErr err);
-
- SpritePtr NewTankSprite( short tankType );
- SpritePtr NewBulletSprite( void );
- SpritePtr NewPowerUpSprite( GunType gunType );
-
- SW_FUNC void TankSpriteMoveProc(SpritePtr tankSpriteP);
- SW_FUNC void BulletSpriteMoveProc(SpritePtr srcSpriteP);
- SW_FUNC void DeadTankFrameProc(SpritePtr tankSpriteP, FramePtr curFrameP, long *frameIndex);
-
- void ShootBullet(SpritePtr tankSpriteP);
-
- SW_FUNC void BulletSpriteCollideProc(
- SpritePtr bulletSpriteP,
- SpritePtr tankSpriteP,
- Rect* sectRect);
-
- SW_FUNC void PowerUpCollideProc(
- SpritePtr powerUpSpriteP,
- SpritePtr tankSpriteP,
- Rect* sectRect);
-
- void DamageTank( SpritePtr tankSpriteP, short damageAmount );
-
- SW_FUNC void TankHitDrawProc(
- FramePtr srcFrameP,
- FramePtr dstFrameP,
- Rect* srcRect,
- Rect* dstRect);
-
-
-