HGE 在 VS2005中的配置

1. Set headers and libraries path

Open Tools->Options->Projects->VC++ Directories, add path to HGE "include" directory and move it to the top:


On the same tab select Library files from the Show directories for dropdown list, add path to HGE "lib\vc" directory and move it to the top:


Press OK.

Now you can use HGE in your projects without specifying it's exact location. This step is needed only once for all your projects.

2. Create blank Win32 Application project

Open File->New...->Projects dialog tab, select Win32 Project, type in your Project name and Location:


Press OK.

On the next screen select Application Settings. Make sure that Windows Application is set under Application Type. Then check Empty project under Additional Options or leave it unchecked if you want a simple file structure to be created for you:


Press Finish. Voila! You have the project created now.

3. Add libraries to the project

Open Project->Properties...->Linker->Input and add to Additional Dependencies the following libraries:

  • hge.lib - HGE system layer DLL import library
  • hgehelp.lib - HGE helper classes library

If you don't call any Windows functions, these two are the only libraries required.


Then select Release from the Configuration dropdown list and repeat the operation.

Press OK.

4. Start coding!

Include hge.h to access HGE functions. See Tutorials section for basic code examples.

 

 

ContractedBlock.gif ExpandedBlockStart.gif Code
// HgeTest.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include 
<Windows.h>
#include 
<hge.h>
#include 
<hgesprite.h>

HGE 
*hge = 0;
hgeSprite 
*spr;//创建精灵类指针 
HTEXTURE tex;//定义一个texture(纹理)对象

bool FrameFunc()
{
    
if (hge->Input_GetKeyState(HGEK_ESCAPE)) 
        
return true;
    
return false;
}
//绘制函数,程序开始后HGE将不停调用它 
bool RenderFunc()

    hge
->Gfx_BeginScene();//开始渲染 
    hge->Gfx_Clear(0xFF000000);//以某颜色清屏,OxFF000000为透明度为0的黑色 
    spr->Render(0,0);//在指定位置显示精灵 
    hge->Gfx_EndScene();//结束渲染 
    return false;//总是返回false 


int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    
//根据版本号创建HGE实例
    hge = hgeCreate(HGE_VERSION);
    
//设置窗口函数
    hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
    
//设置窗口绘制函数
    hge->System_SetState(HGE_RENDERFUNC,RenderFunc);
    
//设置使用窗口模式:true-window mode; false: full screen.
    hge->System_SetState(HGE_WINDOWED, true);
    
//设置窗口大小
    hge->System_SetState(HGE_SCREENWIDTH, 640);//将屏幕宽度设置为800 
    hge->System_SetState(HGE_SCREENHEIGHT,480);//将屏幕高度设置为600 */
    
//是否使用声音
    hge->System_SetState(HGE_USESOUND, false);
    hge
->System_SetState(HGE_TITLE, "HGE Tutorial 01 - Minima HGE application");
    hge
->System_SetState(HGE_HIDEMOUSE,false);
    
//是否显示启动是的logo
    hge->System_SetState(HGE_SHOWSPLASH,false);
    
//启用深度缓冲 - 开启2D空间中的第三根坐标轴
    hge->System_SetState(HGE_ZBUFFER,true); 

    
//启动程序主循环
    if(hge->System_Initiate())
    {
        tex
=hge->Texture_Load("sample.bmp");//根据路径载入图片 
        if(tex)//检测是否图片成功载入
        {
            
int x,y,h,w;
            x
=y=0;
            spr
=new hgeSprite(tex,x,y,640,480);//初始化精灵spr,并且指定tex为它的纹理 
        }
        hge
->System_Start();
    }
    
else
    {    
        MessageBox(NULL, hge
->System_GetErrorMessage(), "Error",
            MB_OK 
| MB_ICONERROR | MB_APPLMODAL);
    }

    hge
->Texture_Free(tex);//释放纹理 
    delete spr;//释放精灵 

    hge
->System_Shutdown();
    hge
->Release();

    
return 0;
}

5、尽管如此,可是运行时还会报错。

原因是找不到hge.dll。好办。直接复制该文件到debug目录下。

再次运行,OK。


转载于:https://www.cnblogs.com/chzhcpu/archive/2009/05/31/1492805.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值