1. 程式人生 > >建立第一個HGE程式

建立第一個HGE程式

新建一個Win32Application 空專案

建立一個C++原始檔

程式碼如下:

#include <hge.h>
HGE *hge = 0;
bool FrameFunc()
{
	//按下Esc鍵,退出程式
	if(hge->Input_GetKeyState(HGEK_ESCAPE))
		return true;
	return false;
}

int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
	//初始化HGE指標
	hge = hgeCreate(HGE_VERSION);
	//設定幀函式
	hge->System_SetState(HGE_FRAMEFUNC,FrameFunc);
	//設定視窗模式,true視窗模式 false 全屏模式
	hge->System_SetState(HGE_WINDOWED,true);
	//設定聲音
	hge->System_SetState(HGE_USESOUND,false);
	//標題升值
	hge->System_SetState(HGE_TITLE,"My Game");
	//完成初始化
	if(hge->System_Initiate())
	{
		hge->System_Start();
	}
	else
	{
		MessageBox(NULL,hge->System_GetErrorMessage(),"Error",MB_OK|MB_ICONERROR|MB_APPLMODAL);
	}

	//釋放資源
	hge->System_Shutdown();
	hge->Release();

	return 0;
}

執行結果: