90 lines
3.4 KiB
C++
90 lines
3.4 KiB
C++
#include <common/purehdc.hpp>
|
|
#include <common/rgbcolor.hpp>
|
|
#include <pop/sprite.hpp>
|
|
|
|
//PureSprite::PureSprite(PureDevice &displayDevice,Point startPoint)
|
|
//: mDisplayDevice(displayDevice)
|
|
//{
|
|
//}
|
|
|
|
PureSprite::PureSprite(void)
|
|
{
|
|
}
|
|
|
|
PureSprite::~PureSprite()
|
|
{
|
|
}
|
|
|
|
PureSprite::operator PureBitmap&(void)
|
|
{
|
|
return mBitmapNothing;
|
|
}
|
|
|
|
void PureSprite::moveSprite(const Point &newPoint)
|
|
{
|
|
// PureBitmap currImage((PureBitmap&)*this);
|
|
PureBitmap bitmapNew;
|
|
PureBitmap bitmapMask;
|
|
PureBitmap bitmapCache;
|
|
PureBitmap bitmapScratch;
|
|
PureDevice memoryDevice;
|
|
PureDevice bkCurrDevice;
|
|
PureDevice bkPrevDevice;
|
|
PureDevice maskDevice;
|
|
PureDevice cacheDevice;
|
|
PureDevice scratchDevice;
|
|
RGBColor rgbColor;
|
|
Point deltaPoint;
|
|
Point currPoint;
|
|
Point currDimPoint(width(),height());
|
|
// Point currDimPoint(currImage.width(),currImage.height());
|
|
|
|
currPoint=newPoint;
|
|
if(mPrevPoint==Point(0,0))mPrevPoint=currPoint;
|
|
deltaPoint.x(mPrevPoint.x()-currPoint.x());
|
|
deltaPoint.y(mPrevPoint.y()-currPoint.y());
|
|
mPrevPoint=currPoint;
|
|
|
|
scratchDevice.compatibleDevice(mDisplayDevice);
|
|
memoryDevice.compatibleDevice(mDisplayDevice);
|
|
bkCurrDevice.compatibleDevice(mDisplayDevice);
|
|
bkPrevDevice.compatibleDevice(mDisplayDevice);
|
|
maskDevice.compatibleDevice(mDisplayDevice);
|
|
cacheDevice.compatibleDevice(mDisplayDevice);
|
|
|
|
rgbColor=::SetBkColor(memoryDevice,RGBColor(0,0,0));
|
|
|
|
bitmapScratch.compatibleBitmap(mDisplayDevice,currDimPoint.x(),currDimPoint.y());
|
|
bitmapNew.compatibleBitmap(mDisplayDevice,currDimPoint.x(),currDimPoint.y());
|
|
bitmapCache.compatibleBitmap(mDisplayDevice,currDimPoint.x(),currDimPoint.y());
|
|
bitmapMask.compatibleBitmap(maskDevice,currDimPoint.x(),currDimPoint.y());
|
|
|
|
memoryDevice.select(currImage);
|
|
scratchDevice.select(bitmapScratch);
|
|
bkCurrDevice.select(bitmapNew);
|
|
bkPrevDevice.select(mBitmapBkGnd);
|
|
maskDevice.select(bitmapMask);
|
|
cacheDevice.select(bitmapCache);
|
|
|
|
// ::StretchBlt(scratchDevice,0,0,bitmapScratch.width(),bitmapScratch.height(),memoryDevice,0,0,currImage.width(),currImage.height(),SRCCOPY);
|
|
// ::StretchBlt(maskDevice,0,0,bitmapMask.width(),bitmapMask.height(),memoryDevice,0,0,currImage.width(),currImage.height(),SRCCOPY);
|
|
::BitBlt(bkCurrDevice,0,0,bitmapNew.width(),bitmapNew.height(),mDisplayDevice,currPoint.x(),currPoint.y(),SRCCOPY);
|
|
::BitBlt(bkCurrDevice,deltaPoint.x(),deltaPoint.y(),mBitmapBkGnd.width(),mBitmapBkGnd.height(),bkPrevDevice,0,0,SRCCOPY);
|
|
::BitBlt(bkPrevDevice,-deltaPoint.x(),-deltaPoint.y(),mBitmapBkGnd.width(),mBitmapBkGnd.height(),maskDevice,0,0,SRCAND);
|
|
::BitBlt(bkPrevDevice,-deltaPoint.x(),-deltaPoint.y(),mBitmapBkGnd.width(),mBitmapBkGnd.height(),scratchDevice,0,0,SRCPAINT);
|
|
::BitBlt(cacheDevice,0,0,bitmapCache.width(),bitmapCache.height(),bkCurrDevice,0,0,SRCCOPY);
|
|
// ::BitBlt(cacheDevice,0,0,bitmapCache.width(),bitmapCache.height(),maskDevice,0,0,SRCAND);
|
|
// ::BitBlt(cacheDevice,0,0,bitmapCache.width(),bitmapCache.height(),scratchDevice,0,0,SRCPAINT);
|
|
// ::BitBlt(mDisplayDevice,currPoint.x(),currPoint.y(),currDimPoint.x(),currDimPoint.y(),cacheDevice,0,0,SRCCOPY);
|
|
// ::BitBlt(mDisplayDevice,currPoint.x()+deltaPoint.x(),currPoint.y()+deltaPoint.y(),mBitmapBkGnd.width(),mBitmapBkGnd.height(),bkPrevDevice,0,0,SRCCOPY);
|
|
|
|
memoryDevice.select(currImage,FALSE);
|
|
bkCurrDevice.select(bitmapNew,FALSE);
|
|
bkPrevDevice.select(mBitmapBkGnd,FALSE);
|
|
maskDevice.select(bitmapMask,FALSE);
|
|
cacheDevice.select(bitmapCache,FALSE);
|
|
::SetBkColor(memoryDevice,rgbColor);
|
|
mBitmapBkGnd=bitmapNew;
|
|
}
|
|
|