mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-12-01 06:49:51 +00:00
1 line
14 KiB
C
1 line
14 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// Dynamics2.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "RectUtils.h"
#define kBalloonStop 8
#define kBalloonStart 310
#define kCopterStart 8
#define kCopterStop 310
#define kDartVelocity 6
#define kDartStop 310
#define kEnemyDropSpeed 8
extern dynaPtr dinahs;
extern short numBands;
extern Boolean evenFrame, twoPlayerGame, onePlayerLeft, playerDead;
//============================================================== Functions
//-------------------------------------------------------------- HandleBalloon
void HandleBalloon (short who)
{
Rect dest;
if (dinahs[who].moving)
{
if (dinahs[who].vVel < 0)
{
if (evenFrame)
{
dinahs[who].frame++;
if (dinahs[who].frame >= 6)
dinahs[who].frame = 0;
}
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if ((numBands > 0) && (DidBandHitDynamic(who)))
{
dinahs[who].frame = 6;
dinahs[who].vVel = kEnemyDropSpeed;
PlayPrioritySound(kPopSound, kPopPriority);
}
else
{
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.bottom -= dinahs[who].vVel;
}
}
else
{
if (evenFrame)
{
dinahs[who].frame++;
if (dinahs[who].frame >= 8)
dinahs[who].frame = 6;
}
VOffsetRect(&dinahs[who].dest, dinahs[who].vVel);
dinahs[who].whole = dinahs[who].dest;
dinahs[who].whole.top -= dinahs[who].vVel;
}
if ((dinahs[who].dest.top <= kBalloonStop) ||
(dinahs[who].dest.bottom >= kBalloonStart))
{
dest = dinahs[who].whole;
QOffsetRect(&dest, playOriginH, playOriginV);
AddRectToWorkRects(&dest);
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyOutSound, kEnemyOutPriority);
dinahs[who].moving = false;
dinahs[who].vVel = -2;
dinahs[who].timer = dinahs[who].count;
dinahs[who].dest.bottom = kBalloonStart;
dinahs[who].dest.top = dinahs[who].dest.bottom -
RectTall(&balloonSrc[0]);
dinahs[who].whole = dinahs[who].dest;
}
}
else // balloon is idle, waiting to appear
{
if (dinahs[who].active)
{
dinahs[who].timer--;
if (dinahs[who].timer <= 0)
{
dinahs[who].moving = true;
if (dinahs[who].count < kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
else if (dinahs[who].timer == kStartSparkle)
{
dest = dinahs[who].dest;
AddSparkle(&dest);
PlayPrioritySound(kEnemyInSound, kEnemyInPriority);
}
}
}
}
//-------------------------------------------------------------- HandleCopter
void HandleCopter (short who)
{
Rect dest;
if (dinahs[who].moving) // is 'copter about?
{
if (dinahs[who].hVel != 0) // 'copter was not shot
{
dinahs[who].frame++;
if (dinahs[who].frame >= 8)
dinahs[who].frame = 0;
if (twoPlayerGame)
{
if (onePlayerLeft)
{
if (playerDead == theGlider.which)
CheckDynamicCollision(who, &theGlider2, false);
else
CheckDynamicCollision(who, &theGlider, false);
}
else
{
CheckDynamicCollision(who, &theGlider, false);
CheckDynamicCollision(who, &theGlider2, false);
}
}
else
CheckDynamicCollision(who, &theGlider, false);
if ((numBands > 0) && (DidBandHitDynamic(who)))
{
dinahs[who].frame = 8;
dinahs[who].hVel = 0;
dinahs[who].vVel = kEnemyDropSpeed;
PlayPri
|