📄 gamedoc.cpp
字号:
//
// if (IsExitTimer())
// {
// m_bExitTimer = false;
// return false;
// }
// else
// return true;
//
// return false;
//}
//
//void JFZGameDoc::HandleOptKey(JFZKeyControl* pControl)
//{
// int nHitCount = 0;
//
// nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_UP);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_UP) == false)
// {
// if (m_pOptView->GetCurOptMenu() == VIBRATE_OPT)
// {
// m_pOptView->SetCurOptMenu(SOUND_OPT);
// }
// else if (m_pOptView->GetCurOptMenu() == SOUND_OPT)
// {
// m_pOptView->SetCurOptMenu(VIBRATE_OPT);
// }
//
// pControl->SetKeyPressStatus(EKEY_UP, true);
// }
// }
//
// // 判断下按键
// nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_DOWN);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_DOWN) == false)
// {
// if (m_pOptView->GetCurOptMenu() == VIBRATE_OPT)
// {
// m_pOptView->SetCurOptMenu(SOUND_OPT);
// }
// else if (m_pOptView->GetCurOptMenu() == SOUND_OPT)
// {
// m_pOptView->SetCurOptMenu(VIBRATE_OPT);
// }
//
// pControl->SetKeyPressStatus(EKEY_DOWN, true);
// }
// }
//
// // 判断右软键
// nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_RIGHTSOFT);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_RIGHTSOFT) == false)
// {
// if (m_pOptView->GetCurOptMenu() == VIBRATE_OPT)
// {
// if (m_pApp->GetVibrate())
// m_pApp->SetVibrate(false);
// else
// m_pApp->SetVibrate(true);
// }
// else if (m_pOptView->GetCurOptMenu() == SOUND_OPT)
// {
// if (m_pApp->GetSoundCfg())
// {
// m_pApp->SetSoundCfgData(false);
// m_pApp->WtriteSoundCfg(false);
// }
// else
// {
// m_pApp->SetSoundCfgData(true);
// m_pApp->WtriteSoundCfg(true);
// }
// }
//
// pControl->SetKeyPressStatus(EKEY_RIGHTSOFT, true);
// }
// }
//
// // 判断选择键
// nHitCount = pControl->GetKeyHitCounts(EKEY_SELECT) + pControl->GetKeyHitCounts(EKEY_LEFTSOFT);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_SELECT) == false
// && pControl->GetKeyPressStatus(EKEY_LEFTSOFT) == false)
// {
// pControl->SetKeyPressStatus(EKEY_SELECT, true);
// pControl->SetKeyPressStatus(EKEY_LEFTSOFT, true);
// m_pOptView->ExitView();
// }
// }
//}
void CGameDoc::SetGameView(CGameView* pGameView)
{
m_pGameView = pGameView;
}
boolean CGameDoc::UpdateGameView()
{
// 处理按键事件
HandleKeyEvent();
if (IsExitTimer())
{
m_bExitTimer = false;
return false;
}
else
{
if (m_pGameView->m_nGameOver == 1)
{
//切换到结束画面
m_pGameView->ExitView(ID_VIEW_STOP);
m_bExitTimer = false;
return false;
}
if (m_pGameView->m_nGameOver == 2)
{
m_pGameView->ExitView(ID_VIEW_MENU);
m_bExitTimer = false;
return false;
}
return true;
}
return true;
}
void CGameDoc::HandleGameKey(CKeyControl* pControl)
{
// int nMenuIndex = m_pGameView->GetMenuIndex(m_pGameView->m_eGameMenu);
int nHitCount = 0;
/************************************************************************/
/* 处理准星 */
/************************************************************************/
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_LEFT);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_LEFT) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
if (m_pGameView->m_tPlayer.m_nCurDoing == 0)
{
m_pGameView->m_tPlayer.m_nCurDoing = 1;
m_pGameView->m_tPlayer.m_nCurDirectX = 0;
m_pGameView->m_tPlayer.m_nCurDirectY = 2;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 0;
}
else if (m_pGameView->m_tPlayer.m_nCurDoing == 2 || m_pGameView->m_tPlayer.m_nCurDoing == 4)
{
if (m_pGameView->m_tPlayer.m_bAclinicMoveable == TRUE)
{
m_pGameView->m_tPlayer.m_nCurDoing = 3;
m_pGameView->m_tPlayer.m_nCurDirectX = 0;
m_pGameView->m_tPlayer.m_nCurDirectY = 2;
m_pGameView->m_tPlayer.m_nCurFaceX = 0;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 1;
m_pGameView->m_tPlayer.m_nJumpNum = 2;
m_pGameView->m_tPlayer.m_nRunSpeedX = INIT_PACE;//-3;
m_pGameView->m_tPlayer.m_bAclinicMoveable = FALSE;
}
}
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_LEFT, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_RIGHT);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_RIGHT) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
if (m_pGameView->m_tPlayer.m_nCurDoing == 0)
{
m_pGameView->m_tPlayer.m_nCurDoing = 1;
m_pGameView->m_tPlayer.m_nCurDirectX = 1;
m_pGameView->m_tPlayer.m_nCurDirectY = 2;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 0;
}
else if (m_pGameView->m_tPlayer.m_nCurDoing == 2 || m_pGameView->m_tPlayer.m_nCurDoing == 4)
{
if (m_pGameView->m_tPlayer.m_bAclinicMoveable == TRUE)
{
m_pGameView->m_tPlayer.m_nCurDoing = 3;
m_pGameView->m_tPlayer.m_nCurDirectX = 1;
m_pGameView->m_tPlayer.m_nCurDirectY = 2;
m_pGameView->m_tPlayer.m_nCurFaceX = 1;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 1;
m_pGameView->m_tPlayer.m_nJumpNum = 2;
m_pGameView->m_tPlayer.m_nRunSpeedX = INIT_PACE;//-3;
m_pGameView->m_tPlayer.m_bAclinicMoveable = FALSE;
}
}
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_RIGHT, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_UP);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_UP) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
if (!m_pGameView->m_bPause)
{
// 人物是站立和第一次跳可以跳
if (m_pGameView->m_tPlayer.m_nCurDoing == 0)
{
m_pGameView->m_tPlayer.m_nCurDoing = 2;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = INIT_PACE;
m_pGameView->m_tPlayer.m_nCurDirectY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 0;
m_pGameView->m_tPlayer.m_nRunDistanceY = 0;
m_pGameView->m_tPlayer.m_bAclinicMoveable = TRUE;
m_pGameView->m_tPlayer.m_nJumpNum++;
}
else if (m_pGameView->m_tPlayer.m_nCurDoing == 2 || m_pGameView->m_tPlayer.m_nCurDoing == 4)
{
if (m_pGameView->m_tPlayer.m_nJumpNum < 2)
{
if (m_pGameView->m_tPlayer.m_nCurDoing == 4)
m_pGameView->m_tPlayer.m_nCurDoing = 2;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunSpeedY = INIT_PACE;
m_pGameView->m_tPlayer.m_nCurDirectY = 0;
m_pGameView->m_tPlayer.m_nRunTime = 0;
m_pGameView->m_tPlayer.m_nRunDistanceY = 0;
m_pGameView->m_tPlayer.m_nJumpNum++;
}
}
}
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_UP, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_DOWN);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_DOWN) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动准星
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// m_pGameView->m_tPost.nPostCurDoing = 4;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_DOWN, true);
}
}
/************************************************************************/
/* 处理人物 */
/************************************************************************/
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_KEY1);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_KEY1) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动人物
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// m_pGameView->m_tPlayer.nCurDoing = 3;
// m_pGameView->m_tPlayer.nCurIndex = 0;
// m_pGameView->m_tPlayer.nPlayerNum = 0;
// m_pGameView->m_tPlayer.bRoll = TRUE;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_KEY1, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_KEY3);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_KEY3) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动人物
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// m_pGameView->m_tPlayer.nCurDoing = 4;
// m_pGameView->m_tPlayer.nCurIndex = 0;
// m_pGameView->m_tPlayer.nPlayerNum = 0;
// m_pGameView->m_tPlayer.bRoll = TRUE;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_KEY3, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_KEY4);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_KEY4) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动人物
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// m_pGameView->m_tPlayer.nCurDoing = 1;
// m_pGameView->m_tPlayer.nCurIndex = 6;
// m_pGameView->m_tPlayer.nPlayerNum = 1;//0;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_KEY4, true);
}
}
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_KEY6);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_KEY6) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动人物
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// m_pGameView->m_tPlayer.nCurDoing = 2;
// m_pGameView->m_tPlayer.nCurIndex = 6;
// m_pGameView->m_tPlayer.nPlayerNum = 1;//0;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_KEY6, true);
}
}
// 释放大枪
nHitCount = m_pKeyControl->GetKeyHitCounts(EKEY_KEY8);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_KEY8) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
// if (!m_pGameView->m_bPause)
// {
// // 人物是站立和准星停止可以移动人物
// if (m_pGameView->m_tPlayer.nCurDoing == 0
// && m_pGameView->m_tPost.nPostCurDoing == 0)
// {
// // 加载玩家武器数据
// m_pGameView->LoadPlayWeapon(2);
// m_pGameView->m_tPlayer.nPlayerNum = 1;//0;
// m_pGameView->m_tPlayer.nWeapon = 2;
// m_pGameView->m_tPlayer.bFireSuper = TRUE;
// m_pGameView->m_tPlayer.nEnergyTime = 0;
// }
// }
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_KEY8, true);
}
}
// 判断选择键(确定和扔雷)
nHitCount = pControl->GetKeyHitCounts(EKEY_SELECT);
if (nHitCount != AVLID_KEY_PRESS_NUM)
{
if (pControl->GetKeyPressStatus(EKEY_SELECT) == false)
{
if (m_pGameView->m_nCurGameStatus == 1)
{
if (m_pGameView->m_tPlayer.m_nCurDoing == 0)
{
m_pGameView->m_tPlayer.m_nCurDoing = 5;
m_pGameView->m_tPlayer.m_nCurDirectX = 2;
m_pGameView->m_tPlayer.m_nCurDirectY = 2;
m_pGameView->m_tPlayer.m_nCurDoingNum = 0;
m_pGameView->m_tPlayer.m_nDoingTimeNum = 0;
m_pGameView->m_tPlayer.m_nRunTime = 0;
}
}
// 释放按键
pControl->SetKeyPressStatus(EKEY_SELECT, true);
}
}
// // 判断左软键
// nHitCount = pControl->GetKeyHitCounts(EKEY_LEFTSOFT);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_LEFTSOFT) == false)
// {
// if (m_pGameView->GetCurGameStatus() == 0)
// {
// m_pGameView->InitCharacterData(true);
// m_pGameView->SetCurGameStatus(1);
// m_pGameView->ReleaseBmpRes();
// m_pGameView->InitGameBgData();
// }
// else if (m_pGameView->GetCurGameStatus() == 1)
// {
// // 初始化游戏数据
// m_pGameView->SetCurGameStatus(2);
// m_pGameView->ReleaseBmpRes();
// m_pGameView->InitGameData();
// }
// else if (m_pGameView->GetCurGameStatus() == 2 && !m_pGameView->m_bCatoonStatus)
// {
// if (!m_pGameView->m_bPause)
// {
// }
// else// 进入相应菜单选择项
// {
// switch (m_pGameView->m_eGameMenu)
// {
// case CONTINUE_GAME:
// m_pGameView->m_bPause = !m_pGameView->m_bPause;
// m_pGameView->ClearScreen();
// break;
// case GANE_HELP:
// m_pGameView->SetCurGameStatus(3);
// m_pGameView->InitGameHelp();// 初始化帮助视图
// break;
// case RETURN_MENU:
// m_pGameView->ExitView(ID_VIEW_MENU);
// break;
// case EXIT_GAME:
// ISHELL_CloseApplet(((JFZGameApp* )GETAPPINSTANCE())->m_pIShell, false);
// break;
// }
// }
// }
// else if (m_pGameView->GetCurGameStatus() == 3)
// {
// m_pGameView->SetCurGameStatus(2);
// m_pGameView->m_bPause = !m_pGameView->m_bPause;
// m_pGameView->ClearScreen();
// }
//
// // 释放按键
// pControl->SetKeyPressStatus(EKEY_LEFTSOFT, true);
// }
// }
//
// // 右软键按下,停止计时器,进入游戏菜单
// nHitCount = pControl->GetKeyHitCounts(EKEY_RIGHTSOFT);
// if (nHitCount != AVLID_KEY_PRESS_NUM)
// {
// if (pControl->GetKeyPressStatus(EKEY_RIGHTSOFT) == false)
// {
// if (m_pGameView->GetCurGameStatus() == 0)
// {
// m_pGameView->ExitView(ID_VIEW_MENU);
// }
// else if (m_pGameView->GetCurGameStatus() == 1)
// {
// m_pGameView->SetCurGameStatus(0);
// m_pGameView->ReleaseBmpRes();
// m_pGameView->InitCharterSelect();
// }
// else if (m_pGameView->GetCurGameStatus() == 2 && !m_pGameView->m_bCatoonStatus)
// {
// m_pGameView->m_bPause = !m_pGameView->m_bPause;
// m_pGameView->ClearScreen();
// }
//
// // 释放按键
// pControl->SetKeyPressStatus(EKEY_RIGHTSOFT, true);
// }
// }
}
void CGameDoc::SetOverView(COverView* pOverView)
{
m_pOverView = pOverView;
}
boolean CGameDoc::UpdateOverView()
{
// 处理按键事件
HandleKeyEvent();
if (IsExitTimer())
{
m_bExitTimer = false;
return false;
}
else
{
if (m_pOverView->m_bReturnMeun)
{
//切换到结束画面
m_pOverView->ExitView();
m_bExitTimer = false;
return false;
}
}
return true;
}
//void CGameDoc::GetTransparentColor(CBitmap* m_pBitmap)
//{
// IBitmap* pbmScreen = NULL;
// IBitmap* pbmDdb = NULL;
// pbmScreen = IDISPLAY_GetDestination(((CGameApp*)GETAPPINSTANCE())->m_pIDisplay);
// IBITMAP_CreateCompatibleBitmap(pbmScreen, &pbmDdb, (uint16)52, (uint16)12);
// IBITMAP_BltIn(pbmDdb, 0, 0, 52, 12, m_pBitmap->m_pIBitmap, 0, 0, AEE_RO_COPY);
// IBITMAP_GetPixel(pbmDdb, 0, 0, &m_Color);
// IBITMAP_Release(pbmDdb);
// IBITMAP_Release(pbmScreen);
//}
void CGameDoc::GetTransparentColor(IBitmap* pbmDdb)
{
// IBitmap* pbmScreen = NULL;
// IBitmap* pbmDdb = NULL;
// pbmScreen = IDISPLAY_GetDestination(((CGameApp*)GETAPPINSTANCE())->m_pIDisplay);
// IBITMAP_CreateCompatibleBitmap(pbmScreen, &pbmDdb, (uint16)52, (uint16)12);
// IBITMAP_BltIn(pbmDdb, 0, 0, 52, 12, m_pIBitmap, 0, 0, AEE_RO_COPY);
IBITMAP_GetPixel(pbmDdb, 0, 0, &m_Color);
// IBITMAP_Release(pbmDdb);
// IBITMAP_Release(pbmScreen);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -