Exemplo n.º 1
0
//************************************************************************
// CLCDGfx::StartTransition
//************************************************************************
void CLCDGfx::StartTransition(ETransitionType eType,LPRECT rect)
{
	if(!m_bInitialized)
		return;

	if(rect != NULL) {
		m_rTransitionRegion.left = rect->left;
		m_rTransitionRegion.right = rect->right;
		m_rTransitionRegion.top = rect->top;
		m_rTransitionRegion.bottom = rect->bottom;
	} else {
		SetRect(&m_rTransitionRegion,0,0,m_nWidth,m_nHeight);
	}

	if(eType == TRANSITION_RANDOM)
		m_eTransition = static_cast<ETransitionType>(GetRandomInt(0,2));
	else
		m_eTransition = eType;

	if(m_bTransition) {
		EndTransition();
		memcpy(m_pBitmapBits,m_pLcdBitmapBits,sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP);
	}

	if(m_pSavedBitmapBits == NULL)
		m_pSavedBitmapBits = (BYTE*)malloc(sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP);

	memcpy(m_pSavedBitmapBits, m_pBitmapBits,sizeof(BYTE)* m_nWidth * m_nHeight * m_nBPP);

	m_dwTransitionStart = 0;

	m_bTransition = true;	
}
Exemplo n.º 2
0
//************************************************************************
// CLCDGfx::Shutdown
//************************************************************************
bool CLCDGfx::Shutdown(void)
{
	EndTransition();

	if(NULL != m_hBitmap)
	{
		DeleteObject(m_hBitmap);
		m_hBitmap = NULL;
		m_pBitmapBits = NULL;
	}

	ASSERT(NULL == m_hPrevBitmap);
	m_hPrevBitmap = NULL;

	if(NULL != m_pBitmapInfo)
	{
		delete [] m_pBitmapInfo;
		m_pBitmapInfo = NULL;
	}

	if(NULL != m_hDC)
	{
		DeleteDC(m_hDC);
		m_hDC = NULL;
	}

	m_nWidth = 0;
	m_nHeight = 0;

	m_bInitialized = false;

	return true;
}
Exemplo n.º 3
0
void Game::Transist()
{
	if (time.IsAfter(transition_ends))
	{
		EndTransition();
	}
}
Exemplo n.º 4
0
void Game::PhaseChange(Phase::Base *next, Time transition_time)
{
	if (!next)
		return;
	if (Transitioning())
		EndTransition();
	transition_ends = TimeNow() + transition_time;
	next_phase = next;
}
Exemplo n.º 5
0
//************************************************************************
// CLCDGfx::EndDraw
//************************************************************************
void CLCDGfx::EndDraw(void)
{
	ASSERT(NULL != m_hPrevBitmap);
	if(NULL != m_hPrevBitmap)
	{
		GdiFlush();
		m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hPrevBitmap);
		ASSERT(m_hPrevBitmap == m_hBitmap);
		m_hPrevBitmap = NULL;
	}

	if(m_nBPP != 1 || !m_bTransition)
		memcpy(m_pLcdBitmapBits, m_pBitmapBits, m_nWidth * m_nHeight * m_nBPP);
	else
	{
		if(m_dwTransitionStart == 0) {
			Cache();
		}

		PBYTE pScreen1 = m_pSavedBitmapBits;
		PBYTE pScreen2 = m_pBitmapBits;

		DWORD dwTimeElapsed = GetTickCount() - m_dwTransitionStart;

		/*	if(m_eTransition == TRANSITION_BT || m_eTransition == TRANSITION_TB)
		{
		int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight;

		if(m_eTransition == TRANSITION_TB)
		{
		iCols = m_nHeight - iCols;

		pScreen1 = m_pBitmapBits;
		pScreen2 = m_pSavedBitmapBits;
		}

		if(iCols > m_nHeight)
		iCols = m_nHeight;
		if(iCols < 0)
		iCols = 0;

		memcpy(m_pLcdBitmapBits,pScreen1+(iCols*m_nWidth),((m_nHeight-iCols)*m_nWidth));
		memcpy(m_pLcdBitmapBits+((m_nHeight-iCols)*m_nWidth),pScreen2,iCols *m_nWidth);
		}
		else if(m_eTransition == TRANSITION_LR || m_eTransition == TRANSITION_RL)
		{
		int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth;

		if(m_eTransition == TRANSITION_LR)
		{
		iCols = m_nWidth - iCols;

		pScreen1 = m_pBitmapBits;
		pScreen2 = m_pSavedBitmapBits;
		}

		if(iCols > m_nWidth)
		iCols = m_nWidth;
		if(iCols < 0)
		iCols = 0;

		for(int i=0;i<m_nHeight;i++)
		{
		memcpy(m_pLcdBitmapBits+(i*m_nWidth),pScreen1+(i*m_nWidth)+iCols,m_nWidth-iCols);
		memcpy(m_pLcdBitmapBits+(i*m_nWidth)+(m_nWidth-iCols),pScreen2+(i*m_nWidth),iCols);
		}
		}
		else*/ if(m_eTransition == TRANSITION_HLINES)
		{
			int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight;
			if(iCols%2 == 1)
				iCols--;

			if(iCols > m_nHeight)
				iCols = m_nHeight;
			if(iCols < 2)
				iCols = 2;

			memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
			for(int i=0;i<m_nHeight;i += m_nHeight/iCols)
				memcpy(m_pLcdBitmapBits+(i*m_nWidth),pScreen2+(i*m_nWidth),m_nWidth);
		}
		else if(m_eTransition == TRANSITION_VLINES)
		{
			int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth;
			if(iCols%2 == 1)
				iCols--;

			if(iCols > m_nWidth)
				iCols = m_nWidth;
			if(iCols < 2)
				iCols = 2;

			memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
			for(int i=0;i<m_nHeight;i++)
			{
				for(int j=0;j<m_nWidth;j+=m_nWidth/iCols)
					memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1);
			}
		}
		else if(m_eTransition == TRANSITION_FADE)
		{
			int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight;
			if(iCols%2 == 1)
				iCols--;

			if(iCols > m_nHeight)
				iCols = m_nHeight;
			if(iCols < 2)
				iCols = 2;

			int iCols2 = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth;
			if(iCols2%2 == 1)
				iCols2--;

			if(iCols2 > m_nWidth)
				iCols2 = m_nWidth;
			if(iCols2 < 2)
				iCols2 = 2;

			memcpy(m_pLcdBitmapBits,pScreen1,m_nHeight*m_nWidth);
			for(int i=0;i<m_nHeight;i += m_nHeight/iCols)
			{
				for(int j=0;j<m_nWidth;j+=m_nWidth/iCols2)
					memcpy(m_pLcdBitmapBits+(i*m_nWidth)+j,pScreen2+(i*m_nWidth)+j,1);
			}
		}
		else if(m_eTransition == TRANSITION_MORPH)
		{
			double dPercent = ((float)dwTimeElapsed/(float)TRANSITION_DURATION);
			double dPixelPercent = dPercent;

			memset(m_pLcdBitmapBits,0x00,m_nHeight * m_nWidth);
			SLCDPixel *pPixel = NULL;
			vector<SLCDPixel*>::iterator iter = m_LMovingPixels.begin();
			int iIndex = 0,iMoved = 0;

			while(iter != m_LMovingPixels.end())
			{
				pPixel = *iter;
				if(pPixel->Position.x != pPixel->Destination.x ||pPixel->Position.y != pPixel->Destination.y) {
					iMoved++;

					dPixelPercent = dPercent * pPixel->dSpeed;
					if(dPixelPercent > 1.0f)
						dPixelPercent = 1.0f;

					if(pPixel->Start.x < pPixel->Destination.x)
						pPixel->Position.x = pPixel->Start.x + dPixelPercent*(pPixel->Destination.x-pPixel->Start.x);
					else if(pPixel->Start.x > pPixel->Destination.x)
						pPixel->Position.x = pPixel->Start.x - dPixelPercent*(pPixel->Start.x-pPixel->Destination.x);

					if(pPixel->Start.y < pPixel->Destination.y)
						pPixel->Position.y = pPixel->Start.y + dPixelPercent*(pPixel->Destination.y-pPixel->Start.y);
					else if(pPixel->Start.y > pPixel->Destination.y)
						pPixel->Position.y = pPixel->Start.y - dPixelPercent*(pPixel->Start.y-pPixel->Destination.y);

				}
				iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x;
				if(iIndex >= 0 && iIndex < m_nHeight * m_nWidth)
					m_pLcdBitmapBits[iIndex] = pPixel->cValue;

				iter++;
			}

			iter = m_LStaticPixels.begin();
			while(iter != m_LStaticPixels.end())
			{	
				pPixel = *iter;

				iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x;
				m_pLcdBitmapBits[iIndex] = pPixel->cValue;
				iter++;
			}
			if(iMoved == 0)
				EndTransition();
		}
		if(m_eTransition != TRANSITION_MORPH && dwTimeElapsed > TRANSITION_DURATION) {
			EndTransition();
		}
	}
	m_dwLastDraw = GetTickCount();
}