mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-29 23:49:30 +00:00
1 line
11 KiB
C
1 line
11 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// Scoreboard.c
//----------------------------------------------------------------------------
//============================================================================
#include <NumberFormatting.h>
#include "Externs.h"
#include "Environ.h"
#include "RectUtils.h"
#define kGrayBackgroundColor 251
#define kGrayBackgroundColor4 10
#define kFoilBadge 0
#define kBandsBadge 1
#define kBatteryBadge 2
#define kHeliumBadge 3
#define kScoreRollAmount 13
void RefreshRoomTitle (short);
void RefreshNumGliders (void);
void RefreshPoints (void);
Rect boardSrcRect, badgeSrcRect, boardDestRect;
GWorldPtr boardSrcMap, badgeSrcMap;
Rect boardTSrcRect, boardTDestRect;
GWorldPtr boardTSrcMap;
Rect boardGSrcRect, boardGDestRect;
GWorldPtr boardGSrcMap;
Rect boardPSrcRect, boardPDestRect;
Rect boardPQDestRect, boardGQDestRect;
Rect badgesBlankRects[4], badgesBadgesRects[4];
Rect badgesDestRects[4];
GWorldPtr boardPSrcMap;
long displayedScore;
short wasScoreboardMode;
Boolean doRollScore;
extern Rect localRoomsDest[], justRoomsRect;
extern long gameFrame;
extern short numNeighbors, otherPlayerEscaped;
extern Boolean evenFrame, onePlayerLeft;
//============================================================== Functions
//-------------------------------------------------------------- RefreshScoreboard
void RefreshScoreboard (short mode)
{
doRollScore = true;
RefreshRoomTitle(mode);
RefreshNumGliders();
RefreshPoints();
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
&boardSrcRect, &boardDestRect, srcCopy, 0L);
QuickBatteryRefresh(false);
QuickBandsRefresh(false);
QuickFoilRefresh(false);
}
//-------------------------------------------------------------- HandleDynamicScoreboard
void HandleDynamicScoreboard (void)
{
#define kFoilLow 2 // 25%
#define kBatteryLow 17 // 25%
#define kHeliumLow -38 // 25%
#define kBandsLow 2 // 25%
long whosTurn;
if (theScore > displayedScore)
{
if (doRollScore)
{
displayedScore += kScoreRollAmount;
if (displayedScore > theScore)
displayedScore = theScore;
}
else
displayedScore = theScore;
PlayPrioritySound(kScoreTikSound, kScoreTikPriority);
QuickScoreRefresh();
}
whosTurn = gameFrame & 0x00000007;
switch (whosTurn)
{
case 0: // show foil
if ((foilTotal > 0) && (foilTotal < kFoilLow))
QuickFoilRefresh(false);
break;
case 1: // hide battery
if ((batteryTotal > 0) && (batteryTotal < kBatteryLow))
QuickBatteryRefresh(true);
else if ((batteryTotal < 0) && (batteryTotal > kHeliumLow))
QuickBatteryRefresh(true);
break;
case 2: // show rubber bands
if ((bandsTotal > 0) && (bandsTotal < kBandsLow))
QuickBandsRefresh(false);
break;
case 4: // show battery
if ((batteryTotal > 0) && (batteryTotal < kBatteryLow))
QuickBatteryRefresh(false);
else if ((batteryTotal < 0) && (batteryTotal > kHeliumLow))
QuickBatteryRefresh(false);
break;
case 5: // hide foil
if ((foilTotal > 0) && (foilTotal < kFoilLow))
QuickFoilRefresh(true);
break;
case 7: // hide rubber bands
if ((bandsTotal > 0) && (bandsTotal < kBandsLow))
QuickBandsRefresh(true);
break;
}
}
//-------------------------------------------------------------- RefreshRoomTitle
void RefreshRoomTitle (short mode)
{
RGBColor theRGBColor, wasColor;
SetPort((GrafPtr)boardTSrcMap);
GetForeColor(&wasColor);
if (thisMac.isDepth == 4)
Index2Color(kGrayBackgroundColor4, &theRGBColor);
else
Index2Color(kGrayBackgroundColor, &theRGBColor);
RGBForeColor(&theRGBColor);
PaintRect(&boardTSrcRect);
RGBForeColor(&wasColor);
MoveTo(1, 10);
ForeColor(blackColor);
switch (mode)
{
case kEscapedTitleMode:
DrawString("\pHit Delete key if unable to Follow");
break;
case kSavingTitleMode:
DrawString("\pSaving Game<6D>");
break;
defa
|