资源说明:HGE引挚
CRect rs;
GetClientRect(pWnd->GetSafeHwnd(),&rs);
hge = hgeCreate(HGE_VERSION);
hge->System_SetState(HGE_LOGFILE, "hge_tut07.log");
//hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
hge->System_SetState(HGE_TITLE, "HGE Tutorial 07 - Thousand of Hares");
hge->System_SetState(HGE_USESOUND, false);
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_SCREENWIDTH, SCREEN_WIDTH);
hge->System_SetState(HGE_SCREENHEIGHT, SCREEN_HEIGHT);
hge->System_SetState(HGE_SCREENBPP, 32);
hge->System_SetState(HGE_HWNDPARENT, pWnd->GetSafeHwnd());
if(hge->System_Initiate())
{
// Load textures
bgtex=hge->Texture_Load("bg2.png");
tex=hge->Texture_Load("zazaka.png");
if(!bgtex || !tex)
{
// If one of the data files is not found,
// display an error message and shutdown
// MessageBox(NULL, "Can't load BG2.PNG or ZAZAKA.PNG", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
hge->System_Shutdown();
hge->Release();
return ;
}
// Load font, create sprites
fnt=new hgeFont("font2.fnt");
spr=new hgeSprite(tex,0,0,64,64);
spr->SetHotSpot(32,32);
bgspr=new hgeSprite(bgtex,0,0,800,600);
bgspr->SetBlendMode(BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_NOZWRITE);
bgspr->SetColor(0xFF000000,0);
bgspr->SetColor(0xFF000000,1);
bgspr->SetColor(0xFF000040,2);
bgspr->SetColor(0xFF000040,3);
// Initialize objects list
pObjects=new sprObject[MAX_OBJECTS];
nObjects=1000;
for(int i=0;iRandom_Float(0,SCREEN_WIDTH);
pObjects[i].y=hge->Random_Float(0,SCREEN_HEIGHT);
pObjects[i].dx=hge->Random_Float(-200,200);
pObjects[i].dy=hge->Random_Float(-200,200);
pObjects[i].scale=hge->Random_Float(0.5f,2.0f);
pObjects[i].dscale=hge->Random_Float(-1.0f,1.0f);
pObjects[i].rot=hge->Random_Float(0,M_PI*2);
pObjects[i].drot=hge->Random_Float(-1.0f,1.0f);
}
SetBlend(0);
// Let's rock now!
hge->System_Start();
// Delete created objects and free loaded resources
delete[] pObjects;
delete fnt;
delete spr;
delete bgspr;
hge->Texture_Free(tex);
hge->Texture_Free(bgtex);
}
// Clean up and shutdown
hge->System_Shutdown();
hge->Release();
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。