![]() |
|
|
bool FrameFunc() { if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true; return false; } The WinMain function is a standard windows application entry point. Here we'll obtain a pointer to HGE interface to access HGE functions. In this example we use global pointer to HGE interface. Instead you may use hgeCreate function every time you need access to HGE. Just be sure to have a corresponding Release call for each call to hgeCreate. WinMain函数是一个标准windows应用程序入口点。在这里我们得到一个HGE接口指针去访问HGE函数。在这个例子中我们使用全局HGE接口指针。每次你需要访问HGE你可以使用hgeCreate函数。每次调用hgeCreate后就可以有一个相应的版本。 int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { hge = hgeCreate(HGE_VERSION); Then we set some internal HGE system states to configure the environment. Although most of the system states have appropriate defaults, at least HGE_FRAMEFUNC must be set before calling System_Start. 然后,我们设置一些内在的HGE系统状态去配置这个环境。虽然大多数系统默认状态都有适当的默认值,至少在调用System_Start之前HGE_FRAMEFUNC必须被设置。 hge->System_SetState(HGE_FRAMEFUNC, FrameFunc); hge->System_SetState(HGE_WINDOWED, true); hge->System_SetState(HGE_USESOUND, false); hge->System_SetState(HGE_TITLE, "HGE Tutorial 01 - Minimal HGE application"); Now we initiate HGE with the states set. If something goes wrong, the System_Initiate function returns false and more specific description of what have happened can be read with System_GetErrorMessage. 现在我们开始HGE的状态设置。如果某些事情发生错误,System_Initate函数返回false并且可以使用System_GetErrorMessage读取关于发生问题的更详细的描述。 Having HGE initiated we start the game loop with call to the System_Start function. The execution "stops" here until true is returned from the frame function. 在HGE初始化之后我们通过调用System_Start函数开始游戏循环。直到从帧函数返回true,在这里执行停止。 if(hge->System_Initiate()) { hge->System_Start(); } else { MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL); } Now ESC has been pressed or the user has closed the window by other means. We should restore video mode and free all allocated resources. Also we should release the HGE interface: 现在ESC被按下或者用户通过其他方法关闭了窗口。我们将恢复显示模式并且释放所有分配的资源。我们也将释放HGE接口: 上一页12 下一页
|