⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sprite.cpp

📁 战场登陆器vc++源代码很好用的哦精彩精彩
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	// 粮犁窍瘤 臼绰 橇饭烙阑 免仿窍咯 沁促.
	if( this == NULL ) return;
	if( m_stBrush == NULL ) return;
	if ((m_iTotalFrame-1 < sFrame) || (sFrame < 0)) return;	
	m_bOnCriticalSection = TRUE;

	sx  = m_stBrush[sFrame].sx;
	sy  = m_stBrush[sFrame].sy;
	szx = m_stBrush[sFrame].szx;
	szy = m_stBrush[sFrame].szy;
	pvx = m_stBrush[sFrame].pvx;
	pvy = m_stBrush[sFrame].pvy;

  	dX = sX + pvx;
	dY = sY + pvy;

	if (dX < m_pDDraw->m_rcClipArea.left) 								  
	{
		sx = sx	+ (m_pDDraw->m_rcClipArea.left - dX);							
		szx = szx - (m_pDDraw->m_rcClipArea.left - dX);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
		dX = (short)m_pDDraw->m_rcClipArea.left;
	}
	else if (dX+szx > m_pDDraw->m_rcClipArea.right)
	{
		szx = szx - ((dX+szx) - (short)m_pDDraw->m_rcClipArea.right);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	if (dY < m_pDDraw->m_rcClipArea.top) 								  
	{
		sy = sy	+ (m_pDDraw->m_rcClipArea.top - dY);
		szy = szy - (m_pDDraw->m_rcClipArea.top - dY);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
		dY = (short)m_pDDraw->m_rcClipArea.top;
	}
	else if (dY+szy > m_pDDraw->m_rcClipArea.bottom)
	{
		szy = szy - ((dY+szy) - (short)m_pDDraw->m_rcClipArea.bottom);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	m_dwRefTime = dwTime;
	
	if (m_bIsSurfaceEmpty == TRUE) {
		if( _iOpenSprite() == FALSE ) return;
	}
	else {
		// AlphaDegree啊 函版登菌促搁 促矫 肺靛茄促.
		if (m_bAlphaEffect && (m_cAlphaDegree != G_cSpriteAlphaDegree)) {
			if (G_cSpriteAlphaDegree == 2) {
				// 鸥老捞 广栏肺 函版登绰 巴捞扼搁 犁肺爹且 鞘夸 绝捞 Alpha Degree父 汲沥茄促.
				_SetAlphaDegree();
			}
			else {
				_iCloseSprite();
				if( _iOpenSprite() == FALSE ) return;
			}
		}
	}

	//SetRect(&m_rcBound, dX, dY, dX + szx, dY + szy);
	m_rcBound.left = dX;
	m_rcBound.top  = dY;
	m_rcBound.right  = dX + szx;
	m_rcBound.bottom = dY + szy;

	pSrc = (WORD *)m_pSurfaceAddr + sx + ((sy)*m_sPitch);
	pDst = (WORD *)m_pDDraw->m_pBackB4Addr + dX + ((dY)*m_pDDraw->m_sBackB4Pitch);

	if ((szx == 0) || (szy == 0)) return;

	switch (m_pDDraw->m_cPixelFormat) {
	case 1:
		iy =0;
		do {
			ix = 0;
			do {
				pDst[ix] = (WORD)((G_lTransRB100[(pDst[ix]&0xF800)>>11][(pSrc[ix]&0xF800)>>11]<<11) | (G_lTransG100[(pDst[ix]&0x7E0)>>5][(pSrc[ix]&0x7E0)>>5]<<5) | G_lTransRB100[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;

	case 2:
		iy =0;
		do {
			ix = 0;
			do {
				pDst[ix] = (WORD)((G_lTransRB100[(pDst[ix]&0x7C00)>>10][(pSrc[ix]&0x7C00)>>10]<<10) | (G_lTransG100[(pDst[ix]&0x3E0)>>5][(pSrc[ix]&0x3E0)>>5]<<5) | G_lTransRB100[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;
	}

	m_bOnCriticalSection = FALSE;
}

void CSprite::PutTransSprite70(int sX, int sY, int sFrame, DWORD dwTime)
{
	short dX,dY,sx,sy,szx,szy,pvx,pvy;
 int  ix, iy;
 WORD * pSrc, * pDst;
 	
	// 粮犁窍瘤 臼绰 橇饭烙阑 免仿窍咯 沁促.
	if( this == NULL ) return;
	if( m_stBrush == NULL ) return;
	if ((m_iTotalFrame-1 < sFrame) || (sFrame < 0)) return;	
	m_bOnCriticalSection = TRUE;

	sx  = m_stBrush[sFrame].sx;
	sy  = m_stBrush[sFrame].sy;
	szx = m_stBrush[sFrame].szx;
	szy = m_stBrush[sFrame].szy;
	pvx = m_stBrush[sFrame].pvx;
	pvy = m_stBrush[sFrame].pvy;

  	dX = sX + pvx;
	dY = sY + pvy;

	if (dX < m_pDDraw->m_rcClipArea.left) 								  
	{
		sx = sx	+ (m_pDDraw->m_rcClipArea.left - dX);							
		szx = szx - (m_pDDraw->m_rcClipArea.left - dX);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
		dX = (short)m_pDDraw->m_rcClipArea.left;
	}
	else if (dX+szx > m_pDDraw->m_rcClipArea.right)
	{
		szx = szx - ((dX+szx) - (short)m_pDDraw->m_rcClipArea.right);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	if (dY < m_pDDraw->m_rcClipArea.top) 								  
	{
		sy = sy	+ (m_pDDraw->m_rcClipArea.top - dY);
		szy = szy - (m_pDDraw->m_rcClipArea.top - dY);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
		dY = (short)m_pDDraw->m_rcClipArea.top;
	}
	else if (dY+szy > m_pDDraw->m_rcClipArea.bottom)
	{
		szy = szy - ((dY+szy) - (short)m_pDDraw->m_rcClipArea.bottom);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	m_dwRefTime = dwTime;
	
	if (m_bIsSurfaceEmpty == TRUE) {
		if( _iOpenSprite() == FALSE ) return;
	}
	else {
		// AlphaDegree啊 函版登菌促搁 促矫 肺靛茄促.
		if (m_bAlphaEffect && (m_cAlphaDegree != G_cSpriteAlphaDegree)) {
			if (G_cSpriteAlphaDegree == 2) {
				// 鸥老捞 广栏肺 函版登绰 巴捞扼搁 犁肺爹且 鞘夸 绝捞 Alpha Degree父 汲沥茄促.
				_SetAlphaDegree();
			}
			else {
				_iCloseSprite();
				if( _iOpenSprite() == FALSE ) return;
			}
		}
	}

	//SetRect(&m_rcBound, dX, dY, dX + szx, dY + szy);
	m_rcBound.left = dX;
	m_rcBound.top  = dY;
	m_rcBound.right  = dX + szx;
	m_rcBound.bottom = dY + szy;

	pSrc = (WORD *)m_pSurfaceAddr + sx + ((sy)*m_sPitch);
	pDst = (WORD *)m_pDDraw->m_pBackB4Addr + dX + ((dY)*m_pDDraw->m_sBackB4Pitch);

	if ((szx == 0) || (szy == 0)) return;

	switch (m_pDDraw->m_cPixelFormat) {
	case 1:
		iy =0;
		do {
			ix = 0;
			do {
				if (pSrc[ix] != m_wColorKey) {
					pDst[ix] = (WORD)((G_lTransRB70[(pDst[ix]&0xF800)>>11][(pSrc[ix]&0xF800)>>11]<<11) | (G_lTransG70[(pDst[ix]&0x7E0)>>5][(pSrc[ix]&0x7E0)>>5]<<5) | G_lTransRB70[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				}
				
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;

	case 2:
		iy =0;
		do {
			ix = 0;
			do {
				if (pSrc[ix] != m_wColorKey) {
					pDst[ix] = (WORD)((G_lTransRB70[(pDst[ix]&0x7C00)>>10][(pSrc[ix]&0x7C00)>>10]<<10) | (G_lTransG70[(pDst[ix]&0x3E0)>>5][(pSrc[ix]&0x3E0)>>5]<<5) | G_lTransRB70[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				}
				
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;
	}

	m_bOnCriticalSection = FALSE;
}


void CSprite::PutTransSprite70_NoColorKey(int sX, int sY, int sFrame, DWORD dwTime)
{
	short dX,dY,sx,sy,szx,szy,pvx,pvy;
 int  ix, iy;
 WORD * pSrc, * pDst;
 	
	// 粮犁窍瘤 臼绰 橇饭烙阑 免仿窍咯 沁促.
	if( this == NULL ) return;
	if( m_stBrush == NULL ) return;
	if ((m_iTotalFrame-1 < sFrame) || (sFrame < 0)) return;	
	m_bOnCriticalSection = TRUE;

	sx  = m_stBrush[sFrame].sx;
	sy  = m_stBrush[sFrame].sy;
	szx = m_stBrush[sFrame].szx;
	szy = m_stBrush[sFrame].szy;
	pvx = m_stBrush[sFrame].pvx;
	pvy = m_stBrush[sFrame].pvy;

  	dX = sX + pvx;
	dY = sY + pvy;

	if (dX < m_pDDraw->m_rcClipArea.left) 								  
	{
		sx = sx	+ (m_pDDraw->m_rcClipArea.left - dX);							
		szx = szx - (m_pDDraw->m_rcClipArea.left - dX);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
		dX = (short)m_pDDraw->m_rcClipArea.left;
	}
	else if (dX+szx > m_pDDraw->m_rcClipArea.right)
	{
		szx = szx - ((dX+szx) - (short)m_pDDraw->m_rcClipArea.right);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	if (dY < m_pDDraw->m_rcClipArea.top) 								  
	{
		sy = sy	+ (m_pDDraw->m_rcClipArea.top - dY);
		szy = szy - (m_pDDraw->m_rcClipArea.top - dY);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
		dY = (short)m_pDDraw->m_rcClipArea.top;
	}
	else if (dY+szy > m_pDDraw->m_rcClipArea.bottom)
	{
		szy = szy - ((dY+szy) - (short)m_pDDraw->m_rcClipArea.bottom);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	m_dwRefTime = dwTime;
	
	if (m_bIsSurfaceEmpty == TRUE) {
		if( _iOpenSprite() == FALSE ) return;
	}
	else {
		// AlphaDegree啊 函版登菌促搁 促矫 肺靛茄促.
		if (m_bAlphaEffect && (m_cAlphaDegree != G_cSpriteAlphaDegree)) {
			if (G_cSpriteAlphaDegree == 2) {
				// 鸥老捞 广栏肺 函版登绰 巴捞扼搁 犁肺爹且 鞘夸 绝捞 Alpha Degree父 汲沥茄促.
				_SetAlphaDegree();
			}
			else {
				_iCloseSprite();
				if( _iOpenSprite() == FALSE ) return;
			}
		}
	}

	//SetRect(&m_rcBound, dX, dY, dX + szx, dY + szy);
	m_rcBound.left = dX;
	m_rcBound.top  = dY;
	m_rcBound.right  = dX + szx;
	m_rcBound.bottom = dY + szy;

	pSrc = (WORD *)m_pSurfaceAddr + sx + ((sy)*m_sPitch);
	pDst = (WORD *)m_pDDraw->m_pBackB4Addr + dX + ((dY)*m_pDDraw->m_sBackB4Pitch);

	if ((szx == 0) || (szy == 0)) return;

	switch (m_pDDraw->m_cPixelFormat) {
	case 1:
		iy =0;
		do {
			ix = 0;
			do {
				pDst[ix] = (WORD)((G_lTransRB70[(pDst[ix]&0xF800)>>11][(pSrc[ix]&0xF800)>>11]<<11) | (G_lTransG70[(pDst[ix]&0x7E0)>>5][(pSrc[ix]&0x7E0)>>5]<<5) | G_lTransRB70[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;

	case 2:
		iy =0;
		do {
			ix = 0;
			do {
				pDst[ix] = (WORD)((G_lTransRB70[(pDst[ix]&0x7C00)>>10][(pSrc[ix]&0x7C00)>>10]<<10) | (G_lTransG70[(pDst[ix]&0x3E0)>>5][(pSrc[ix]&0x3E0)>>5]<<5) | G_lTransRB70[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;
	}

	m_bOnCriticalSection = FALSE;
}

void CSprite::PutTransSprite50(int sX, int sY, int sFrame, DWORD dwTime)
{
	short dX,dY,sx,sy,szx,szy,pvx,pvy;
 int  ix, iy;
 WORD * pSrc, * pDst;
 	
	// 粮犁窍瘤 臼绰 橇饭烙阑 免仿窍咯 沁促.
	if( this == NULL ) return;
	if( m_stBrush == NULL ) return;
	if ((m_iTotalFrame-1 < sFrame) || (sFrame < 0)) return;	
	m_bOnCriticalSection = TRUE;

	sx  = m_stBrush[sFrame].sx;
	sy  = m_stBrush[sFrame].sy;
	szx = m_stBrush[sFrame].szx;
	szy = m_stBrush[sFrame].szy;
	pvx = m_stBrush[sFrame].pvx;
	pvy = m_stBrush[sFrame].pvy;

  	dX = sX + pvx;
	dY = sY + pvy;

	if (dX < m_pDDraw->m_rcClipArea.left) 								  
	{
		sx = sx	+ (m_pDDraw->m_rcClipArea.left - dX);							
		szx = szx - (m_pDDraw->m_rcClipArea.left - dX);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
		dX = (short)m_pDDraw->m_rcClipArea.left;
	}
	else if (dX+szx > m_pDDraw->m_rcClipArea.right)
	{
		szx = szx - ((dX+szx) - (short)m_pDDraw->m_rcClipArea.right);
		if (szx < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	if (dY < m_pDDraw->m_rcClipArea.top) 								  
	{
		sy = sy	+ (m_pDDraw->m_rcClipArea.top - dY);
		szy = szy - (m_pDDraw->m_rcClipArea.top - dY);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
		dY = (short)m_pDDraw->m_rcClipArea.top;
	}
	else if (dY+szy > m_pDDraw->m_rcClipArea.bottom)
	{
		szy = szy - ((dY+szy) - (short)m_pDDraw->m_rcClipArea.bottom);
		if (szy < 0) {
			m_rcBound.top = -1;
			return;
		}
	}

	m_dwRefTime = dwTime;
	
	if (m_bIsSurfaceEmpty == TRUE) {
		if( _iOpenSprite() == FALSE ) return;
	}
	else {
		// AlphaDegree啊 函版登菌促搁 促矫 肺靛茄促.
		if (m_bAlphaEffect && (m_cAlphaDegree != G_cSpriteAlphaDegree)) {
			if (G_cSpriteAlphaDegree == 2) {
				// 鸥老捞 广栏肺 函版登绰 巴捞扼搁 犁肺爹且 鞘夸 绝捞 Alpha Degree父 汲沥茄促.
				_SetAlphaDegree();
			}
			else {
				_iCloseSprite();
				if( _iOpenSprite() == FALSE ) return;
			}
		}
	}

	//SetRect(&m_rcBound, dX, dY, dX + szx, dY + szy);
	m_rcBound.left = dX;
	m_rcBound.top  = dY;
	m_rcBound.right  = dX + szx;
	m_rcBound.bottom = dY + szy;

	pSrc = (WORD *)m_pSurfaceAddr + sx + ((sy)*m_sPitch);
	pDst = (WORD *)m_pDDraw->m_pBackB4Addr + dX + ((dY)*m_pDDraw->m_sBackB4Pitch);

	if ((szx == 0) || (szy == 0)) return;

	switch (m_pDDraw->m_cPixelFormat) {
	case 1:
		iy =0;
		do {
			ix = 0;
			do {
				if (pSrc[ix] != m_wColorKey) {
					pDst[ix] = (WORD)((G_lTransRB50[(pDst[ix]&0xF800)>>11][(pSrc[ix]&0xF800)>>11]<<11) | (G_lTransG50[(pDst[ix]&0x7E0)>>5][(pSrc[ix]&0x7E0)>>5]<<5) | G_lTransRB50[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				}
				
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;

	case 2:
		iy =0;
		do {
			ix = 0;
			do {
				if (pSrc[ix] != m_wColorKey) {
					pDst[ix] = (WORD)((G_lTransRB50[(pDst[ix]&0x7C00)>>10][(pSrc[ix]&0x7C00)>>10]<<10) | (G_lTransG50[(pDst[ix]&0x3E0)>>5][(pSrc[ix]&0x3E0)>>5]<<5) | G_lTransRB50[(pDst[ix]&0x1F)][(pSrc[ix]&0x1F)]);
				}
				
				ix++;
			} while (ix < szx);
			pSrc += m_sPitch;
			pDst += m_pDDraw->m_sBackB4Pitch;
			iy++;
		} while (iy < szy);
		break;
	}

	m_bOnCriticalSection = FALSE;
}


void CSprite::PutTransSprite50_NoColorKey(int sX, int sY, int sFrame, DWORD dwTime)
{
	short dX,dY,sx,sy,szx,szy,pvx,pvy;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -