GameFrame.cpp
上传用户:maxiaolivb
上传日期:2022-06-07
资源大小:915k
文件大小:2k
- #include ".gameframe.h"
- #include "EditCtrl.h"
- GameFrame::GameFrame(void)
- {
- m_pGuiManager = NULL;
- }
- GameFrame::~GameFrame(void)
- {
- DELETE_OBJECT(m_pGuiManager);
- }
- //初始化游戏框架
- bool GameFrame::InitGameFrame()
- {
- m_pGuiManager = new GuiManager;
- if (!m_pGuiManager)
- {
- g_pHGE->System_Log("图形用户接口管理器创建失败!");
- return false;
- }
- if (!InitAllCtrl())
- return false;
- m_pGuiManager->SetNavMode(HGEGUI_UPDOWN | HGEGUI_CYCLED);
- m_pGuiManager->Enter();
- return true;
- }
- //退出游戏框架
- bool GameFrame::ExitGameFrame()
- {
- if (!DeleteAllCtrl())
- return false;
- return true;
- }
- //游戏控制循环
- bool GameFrame::GameFrameRun()
- {
- if (g_pHGE->Input_GetKeyState(HGEK_ESCAPE))
- {
- DestroyWindow(g_pHGE->System_GetState(HGE_HWND));
- }
- static bool m_bLLastPressed = false;
- static bool m_bLPressed = false;
- m_bLLastPressed = m_bLPressed;
- m_bLPressed = g_pHGE->Input_GetKeyState(VK_LBUTTON);
- if(!m_bLLastPressed && m_bLPressed) // 鼠标左键按下
- {
- }
- else if(m_bLLastPressed && !m_bLPressed) // 鼠标左键松开
- {
- }
- return false;
- }
- //游戏绘制循环
- bool GameFrame::GameRenderRun()
- {
- float _fDt = g_pHGE->Timer_GetDelta();
- float _fTime = g_pHGE->Timer_GetTime();
- int _nFPS = g_pHGE->Timer_GetFPS();
- float _fPosX,_fPosY;
- int _fFocusCtrl = m_pGuiManager->Update(_fDt);
- m_pGuiManager->Render();
- g_pHGE->Input_GetMousePos(&_fPosX,&_fPosY);
- g_pFont->printf(5,5,0,"123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- g_pFontCN->SetColor(0xFFFFFFFF);
- g_pFontCN->printf(5,30,"Delte = %0.3fnTime = %fnFPS = %dn鼠标坐标 = %.f:%.f",_fDt,_fTime,_nFPS,_fPosX,_fPosY);
- return false;
- }
- //初始化所有控件
- bool GameFrame::InitAllCtrl()
- {
- //添加编辑控件
- m_pGuiManager->AddCtrl(new EditCtrl(SYSTEM_CTRLID_EDIT,100,300,500,16,0xffff0000,0xffff00ff));
- g_pEditCtrl = (EditCtrl*)m_pGuiManager->GetCtrl(SYSTEM_CTRLID_EDIT);
- return true;
- }
- //删除所有控件
- bool GameFrame::DeleteAllCtrl()
- {
- return true;
- }