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

📄 pokegame.cpp

📁 Brew下的塔罗牌游戏。游戏功能完整
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			if ((m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1) % 13 == m_nPosResult)
			{
				//最后抽到的K特殊处理
				if (m_nPosResult ==12)
				{
					m_nAnimeStep = 8;
					m_nDelayms = FP_STEP5_DELAY_SPECIAL;
				}
				else
					m_nAnimeStep = 7;
				m_ptAnime3.x = m_ptAnime2.x - j;
				m_ptAnime3.y = m_ptAnime2.y - j;
			}
			else
			{
				//如果1次纸牌队列空
				if (m_nPosQueue_2 + m_nPosResult == TOTALPOKES)
				{
					m_nAnimeStep = 6;
					m_ptAnime3.x = m_ptAnime2.x;
					m_ptAnime3.y = m_ptAnime2.y;
				}
				else
					m_nAnimeStep = 1;
			}
		}
		break;
	case 6://1次纸牌队列用完,移动2次纸牌队列到1次的位置
		//画结果队列
		for (i = 0;i < m_nPosResult;i++)
			m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);

		//改变坐标
		if (m_ptAnime3.x - FRAMESKIP * FP_STEP6_MOVE >= m_ptAnime1.x)
			m_ptAnime3.x -= FRAMESKIP * FP_STEP6_MOVE;//FP_STEP6_MOVE倍速度移动
		else
			m_ptAnime3.x = m_ptAnime1.x;
		//画2次纸牌队列
		for (j = 0;j < m_nPosQueue_2 / POKESPERPIXEL + 1;j++)
			m_pBmpBuffer->BltIn(m_ptAnime3.x - j, m_ptAnime3.y - j, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1), 0, AEE_RO_TRANSPARENT);

		//移动完毕
		if (m_ptAnime3.x == m_ptAnime1.x)
		{
			//牌值转移
			for (i = 0;i < m_nPosQueue_2;i++)
			{
				m_arwPKQueue[i] = m_arwPKQueue_2[i];
				m_arwPKQueue_2[i] = 0;
			}
			m_nPosQueue = 0;
			m_nPosQueue_2 = 0;
			m_nAnimeStep = 1;
			m_nDelayms = FP_STEP6_DELAY;
		}
		break;
	case 7://向结果队列移动
		//画1次队列
		j = 0;
		if (m_nPosQueue_2 + m_nPosResult + 1 < TOTALPOKES)
			for (;j < (TOTALPOKES - 1 - m_nPosResult - m_nPosQueue_2) / POKESPERPIXEL + 1;j++)
				m_pBmpBuffer->BltIn(m_ptAnime1.x - j, m_ptAnime1.y - j, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, BK_POKE_POS, 0, AEE_RO_TRANSPARENT);
		//画结果队列
		for (i = 0;i < m_nPosResult;i++)
			m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);

		//画2次队列
		if (m_nPosQueue_2 > 1)
			for (i = 0;i < m_nPosQueue_2 / POKESPERPIXEL + 1;i++)
				m_pBmpBuffer->BltIn(m_ptAnime2.x - i, m_ptAnime2.y - i, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 2] - 1), 0, AEE_RO_TRANSPARENT);

		//计算移动后的坐标。
		//如果距离大于一步
		if (m_ptAnime3.y - DISTANCE_EDGE >= FRAMESKIP * FP_STEP7_MOVE)
		{
			m_ptAnime3.y -= FRAMESKIP * FP_STEP7_MOVE;//FP_STEP7_MOVE倍速度移动
			m_ptAnime3.x = m_ptAnime2.x - i + (m_ptAnime2.y - i - m_ptAnime3.y) * (DISTANCE_EDGE + m_nPokeDistance * m_nPosResult - (m_ptAnime2.x - i))/ (m_ptAnime2.y - i - DISTANCE_EDGE);
		}
		else
		{
			m_ptAnime3.y = DISTANCE_EDGE;
			m_ptAnime3.x = DISTANCE_EDGE + m_nPokeDistance * m_nPosResult;
		}

		//画被移动的牌
		m_pBmpBuffer->BltIn(m_ptAnime3.x, m_ptAnime3.y, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1), 0, AEE_RO_TRANSPARENT);

		//如果移动完毕
		if (m_ptAnime3.y == DISTANCE_EDGE)
		{
			m_arwResult[m_nPosResult] = m_arwPKQueue_2[m_nPosQueue_2 - 1];
			m_nPosQueue_2--;
			m_nPosResult++;
			//如果2次纸牌队列空
			if (m_nPosQueue_2 == 0)
				m_nAnimeStep = 1;
			else
			{
				m_nAnimeStep = 5;
				m_ptAnime3.x = m_ptAnime2.x - j;
			}
			m_nDelayms = FP_STEP7_DELAY;
		}
		break;
	case 8://特殊处理K,第1步,横向移动到正中央
		//画1次队列
		j = 0;
		if (m_nPosQueue_2 + m_nPosResult < TOTALPOKES)
			for (;j < (TOTALPOKES - 1 - m_nPosResult - m_nPosQueue_2) / POKESPERPIXEL + 1;j++)
				m_pBmpBuffer->BltIn(m_ptAnime1.x - j, m_ptAnime1.y - j, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, BK_POKE_POS, 0, AEE_RO_TRANSPARENT);
		//画结果队列
		for (i = 0;i < m_nPosResult;i++)
			m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);

		//计算移动后的坐标。只是横向移动
		//如果距离大于一步
		if (m_ptAnime3.x - (m_cxScreen - m_rtPoke.x) / 2 >= FRAMESKIP * FP_STEP8_MOVE)
			m_ptAnime3.x -= FRAMESKIP * FP_STEP8_MOVE;//FP_STEP8_MOVE倍速度移动
		else
			m_ptAnime3.x = (m_cxScreen - m_rtPoke.x) / 2;

		//画2次队列
		if (m_nPosQueue_2 > 1)
			for (i = 0;i < m_nPosQueue_2 / POKESPERPIXEL + 1;i++)
				m_pBmpBuffer->BltIn(m_ptAnime2.x - i, m_ptAnime2.y - i, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 2] - 1), 0, AEE_RO_TRANSPARENT);

		//画被移动的牌
		m_pBmpBuffer->BltIn(m_ptAnime3.x, m_ptAnime3.y, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1), 0, AEE_RO_TRANSPARENT);

		//如果移动完毕
		if (m_ptAnime3.x == (m_cxScreen - m_rtPoke.x) / 2)
		{
			m_nAnimeStep = 9;
			m_nDelayms = FP_STEP8_DELAY;
		}
		break;
	case 9://特殊处理K,第2步,纵向移动到顶端
		//画1次队列
		j = 0;
		if (m_nPosQueue_2 + m_nPosResult < TOTALPOKES)
			for (;j < (TOTALPOKES - 1 - m_nPosResult - m_nPosQueue_2) / POKESPERPIXEL + 1;j++)
				m_pBmpBuffer->BltIn(m_ptAnime1.x - j, m_ptAnime1.y - j, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, BK_POKE_POS, 0, AEE_RO_TRANSPARENT);
		//画结果队列
		for (i = 0;i < m_nPosResult;i++)
			m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);

		//计算移动后的坐标。只是纵向移动
		//如果距离大于一步
		if (m_ptAnime3.y - DISTANCE_EDGE >= FRAMESKIP * FP_STEP9_MOVE)
			m_ptAnime3.y -= FRAMESKIP * FP_STEP9_MOVE;//FP_STEP9_MOVE倍速度移动
		else
			m_ptAnime3.y = DISTANCE_EDGE;

		//画2次队列
		if (m_nPosQueue_2 > 1)
			for (i = 0;i < m_nPosQueue_2 / POKESPERPIXEL + 1;i++)
				m_pBmpBuffer->BltIn(m_ptAnime2.x - i, m_ptAnime2.y - i, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 2] - 1), 0, AEE_RO_TRANSPARENT);

		//画被移动的牌
		m_pBmpBuffer->BltIn(m_ptAnime3.x, m_ptAnime3.y, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1), 0, AEE_RO_TRANSPARENT);

		//如果移动完毕
		if (m_ptAnime3.y == DISTANCE_EDGE)
		{
			m_nAnimeStep = 10;
			m_ptAnime3.x -= FRAMESKIP * FP_STEP9_BACK;//后错FP_STEP9_BACK格
			//延迟500ms
			m_nDelayms = FP_STEP9_DELAY;
		}
		break;
	case 10://特殊处理K,第3步,横向移动到相应位置
		//画1次队列
		j = 0;
		if (m_nPosQueue_2 + m_nPosResult < TOTALPOKES)
			for (;j < (TOTALPOKES - 1 - m_nPosResult - m_nPosQueue_2) / POKESPERPIXEL + 1;j++)
				m_pBmpBuffer->BltIn(m_ptAnime1.x - j, m_ptAnime1.y - j, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, BK_POKE_POS, 0, AEE_RO_TRANSPARENT);
		//画结果队列
		for (i = 0;i < m_nPosResult;i++)
			m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);

		//计算移动后的坐标。只是横向移动
		//如果距离大于一步
		if ((DISTANCE_EDGE + m_nPokeDistance * 12) - m_ptAnime3.x >= FRAMESKIP * FP_STEP10_MOVE)
			m_ptAnime3.x += FRAMESKIP * FP_STEP10_MOVE;//5倍速度移动
		else
			m_ptAnime3.x = DISTANCE_EDGE + m_nPokeDistance * 12;

		//画2次队列
		if (m_nPosQueue_2 > 1)for (i = 0;i < m_nPosQueue_2 / POKESPERPIXEL + 1;i++)
			m_pBmpBuffer->BltIn(m_ptAnime2.x - i, m_ptAnime2.y - i, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 2] - 1), 0, AEE_RO_TRANSPARENT);

		//画被移动的牌
		m_pBmpBuffer->BltIn(m_ptAnime3.x, m_ptAnime3.y, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwPKQueue_2[m_nPosQueue_2 - 1] - 1), 0, AEE_RO_TRANSPARENT);

		//如果移动完毕
		if (m_ptAnime3.x == DISTANCE_EDGE + m_nPokeDistance * 12)
		{
			m_arwResult[m_nPosResult] = m_arwPKQueue_2[m_nPosQueue_2 - 1];
			m_nPosQueue_2--;
			m_nPosResult++;
			m_nStatus = STATUS_RESULT;
			m_nAnimeStep = 0;
			//延迟500ms
			m_nDelayms = FP_STEP10_DELAY;
			//set result
			m_pPokeResult->SetText(NULL, NULL);
			int i;
			AECHAR szResult[BUFFERSIZE_RESULT];
			for(i=0; i<13; i++)
			{
				if(m_pShell->LoadResString(POKE_RES_FILE, IDS_RESULT1 + m_arwResult[i] - 1, szResult, BUFFERSIZE_RESULT * sizeof(AECHAR))
					> 0)
				{
					m_pPokeResult->SetTextEx((byte *)szResult, NULL, TRUE);
					//Add enter
					AECHAR szEnter[] = {'\r', '\n', 0};
					m_pPokeResult->SetTextEx((byte *)szEnter, NULL, TRUE);
				}
			}
			//Add avoid responsibility declare
			if(m_pShell->LoadResString(POKE_RES_FILE, IDS_HELPTEXT2, szResult, BUFFERSIZE_RESULT * sizeof(AECHAR))
					> 0)
				m_pPokeResult->SetTextEx((byte *)szResult, NULL, TRUE);
			//set active
			m_pPokeResult->SetActive(TRUE);
		}
		break;
	}
	UpdateEx();

	//m_nProcess在0-25间变化,0-10显示文字。
	if (m_nProcess < 11 && m_nPosResult < 13)
	{
		/*
		//文字闪动
		int nChars = 0;
		AECHAR* pString = (AECHAR *)MALLOC(sizeof(AECHAR) * 21);
		if(!pString)
			return;

		if (0 == (nChars = m_pShell->LoadResString(POKE_RES_FILE, IDS_FP1 + m_nPosResult, pString, 20)))
		{
			FREE(pString);
			return;
		}
		if (SUCCESS != m_pDisplay->DrawText(AEE_FONT_NORMAL, pString, nChars, (m_cxScreen - m_pDisplay->MeasureText(AEE_FONT_NORMAL, pString)) / 2, m_cyScreen -  m_nCharHeight, NULL, IDF_TEXT_TRANSPARENT))
		{
			FREE(pString);
			return;
		}
		FREE(pString);
		*/
	}

	if (m_nProcess >= 25 || m_nPosResult == 13)
		m_nProcess = 0;
	else
		m_nProcess++;
}

void CPokeGame::ShowResult(void)
{
	//循环用变量
	int i;

	//显示占卜结果
	//画结果纸牌队列
	for (i = 0;i < m_nPosResult;i++)
		m_pBmpBuffer->BltIn(DISTANCE_EDGE + m_nPokeDistance * i, DISTANCE_EDGE, m_rtPoke.x, m_rtPoke.y, m_pBmpPoke, m_rtPoke.x * (m_arwResult[i] - 1), 0, AEE_RO_TRANSPARENT);
	//Display poke to screen
	m_pDisplay->BitBlt(0, 0, m_cxScreen, m_cyScreen, m_pBmpBuffer->GetHandle(), 0, 0, AEE_RO_COPY);

	//Display static control
	m_pPokeResult->Redraw();
	//
	m_pDisplay->Update();
}

int CPokeGame::Random(int rand)
{
	int rtn;
	byte bRand[2];
	GETRAND(bRand, 2);
	rtn = bRand[0] * bRand[1];
	rtn %= rand;
	return rtn;
}


void CPokeGame::StrFlash(uint16 nResID)
{
	uint16 nChars = WSTRLEN(m_szFlashText);
	m_pDisplay->DrawText(AEE_FONT_NORMAL, m_szFlashText, nChars - 3 + m_nProcess / 4, (m_cxScreen - m_pDisplay->MeasureText(AEE_FONT_NORMAL, m_szFlashText)) / 2, m_cyScreen -  m_nCharHeight, NULL, IDF_TEXT_TRANSPARENT);

	if (m_nProcess >= 15)
		m_nProcess = 0;
	else
		m_nProcess++;
}

⌨️ 快捷键说明

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