mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-29 07:49:46 +00:00
1 line
7.5 KiB
C
1 line
7.5 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// Grease.c
//----------------------------------------------------------------------------
//============================================================================
#include "Externs.h"
#include "Environ.h"
#include "MainWindow.h"
#include "Objects.h"
#include "RectUtils.h"
#include "Room.h"
#define kGreaseIdle 0
#define kGreaseFalling 1
#define kGreaseSpreading 2
#define kGreaseSpiltIdle 3
void BackupGrease (Rect *, short, Boolean);
greasePtr grease;
short numGrease;
extern hotPtr hotSpots;
extern savedType savedMaps[];
extern Point shieldPt;
extern Rect greaseSrcRt[], greaseSrcLf[], shieldRect;
//============================================================== Functions
//-------------------------------------------------------------- HandleGrease
// Goes through all grease objects currently on screen and handles<65>
// them. If they're upright, nothing happens, but if they're in<69>
// the course of falling or spilling, this function will handle<6C>
// advancing the spill, etc.
void HandleGrease (void)
{
Rect src;
short i;
if (numGrease == 0)
return;
for (i = 0; i < numGrease; i++)
{
if (grease[i].mode == kGreaseFalling)
{
grease[i].frame++;
if (grease[i].frame >= 3) // grease completely tipped
{
grease[i].frame = 3;
grease[i].mode = kGreaseSpreading;
hotSpots[grease[i].hotNum].action = kSlideIt;
hotSpots[grease[i].hotNum].isOn = true;
if (grease[i].isRight)
QSetRect(&src, 0, -2, 2, 0);
else
QSetRect(&src, -2, -2, 0, 0);
QOffsetRect(&src, -playOriginH, -playOriginV);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
hotSpots[grease[i].hotNum].bounds = src;
}
QSetRect(&src, 0, 0, 32, 27);
QOffsetRect(&src, 0, grease[i].frame * 27);
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[grease[i].mapNum].map),
(BitMap *)*GetGWorldPixMap(workSrcMap),
&src, &grease[i].dest,
srcCopy, nil);
CopyBits((BitMap *)*GetGWorldPixMap(savedMaps[grease[i].mapNum].map),
(BitMap *)*GetGWorldPixMap(backSrcMap),
&src, &grease[i].dest,
srcCopy, nil);
AddRectToWorkRects(&grease[i].dest);
if (grease[i].isRight)
QOffsetRect(&grease[i].dest, 2, 0);
else
QOffsetRect(&grease[i].dest, -2, 0);
}
else if (grease[i].mode == kGreaseSpreading)
{
if (grease[i].isRight)
{
QSetRect(&src, 0, -2, 2, 0);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
grease[i].start += 2;
hotSpots[grease[i].hotNum].bounds.right += 2;
}
else
{
QSetRect(&src, -2, -2, 0, 0);
QOffsetRect(&src, grease[i].start, grease[i].dest.bottom);
grease[i].start -= 2;
hotSpots[grease[i].hotNum].bounds.left -= 2;
}
{
CGrafPtr wasCPort;
GDHandle wasWorld;
GetGWorld(&wasCPort, &wasWorld);
SetGWorld(backSrcMap, nil);
PaintRect(&src);
SetGWorld(workSrcMap, nil);
PaintRect(&src);
AddRectToWorkRects(&src);
SetGWorld(wasCPort, wasWorld);
}
if (grease[i].isRight)
{
if (grease[i].start >= grease[i].stop)
grease[i].mode = kGreaseSpiltIdle;
}
else
{
if (grease[i].start <= grease[i].stop)
grease[i].mode = kGreaseSpiltIdle;
}
}
}
}
//-------------------------------------------------------------- BackupGrease
// This makes copies of the region of the screen the grease is about<75>
// to be drawn to. It is called in the "set up" when a player has<61>
// just entered a new room. The "grease jar falling over" animation<6F>
// is set up here.
void BackupGrease (Rect *src, short index, Boolean isRight)
{
Rect dest;
short i;
QSetRect(&dest, 0, 0, 32, 27);
for (i = 0; i < 4; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
(BitMap *)*GetGWorldPixMap(savedMaps[index].map),
src, &dest, srcCopy, nil);
if (isRight)
{
CopyMask((BitMap *)*GetGWorldPixMap(bonusSrcMap),
(BitMap
|