#include <ggebase.h>
#include <ggesprite.h>
#include <ggetexture.h>
#include <ggeanimation.h>
#pragma comment(lib, "galaxy2d")
using namespace gge;
ggeTexture *Bgtex;
ggeSprite *Bgspr;
ggeTexture *Playertex;
ggeAnimation *PlayerAni[2];
//帧函数
bool Frame()
{
if (Input_IsKeyDown(GGEK_ESCAPE)) return true;
PlayerAni[1]->Update(1.0);
Graph_BeginScene();
Graph_Clear();
Bgspr->Render(0,0);
PlayerAni[0]->Render(150,150);
PlayerAni[1]->Render(300,150);
Graph_EndScene();
return false;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
//创建游戏引擎
if (!Engine_Create(GGE_VERSION)) return 0;
System_SetState(GGE_TITLE, "剑侠情缘DIY");
System_SetState(GGE_SCREENMODE,SCREEN_WINDOWED);
System_SetState(GGE_SCREENWIDTH,800);
System_SetState(GGE_SCREENHEIGHT,600);
System_SetState(GGE_SCREENBPP,16);
System_SetState(GGE_HIDEMOUSE,false);
//设置帧函数
System_SetState(GGE_FRAMEFUNC, Frame);
//设置帧率
System_SetState(GGE_FPS, 60);
System_SetState(GGE_LOGNAME,"GAMEPROCESS.LOG");
//系统初始化
if (System_Initiate())
{
Bgtex = Texture_Load("背景.jpg");
Bgspr = Sprite_Create(Bgtex,0,0,800,600);
Playertex = Texture_Load("Player1.png");
PlayerAni[0] = Animation_Create(Playertex,8,8,48,96,0,0);
PlayerAni[1] = Animation_Create(Playertex,8,8,48,96,0,96*1);
int aniFrame = PlayerAni[1]->GetFrame();
PlayerAni[1]->SetTextureRect(0, 1 * PlayerAni[1]->GetHeight(), PlayerAni[1]->GetWidth(), PlayerAni[1]->GetHeight());
PlayerAni[1]->SetFrame(aniFrame);
PlayerAni[0]->Play();
PlayerAni[1]->Play();
//开始运行帧函数
System_Start();
}
SAFE_RELEASE(Bgtex);
SAFE_RELEASE(Bgspr);
SAFE_RELEASE(Playertex);
for(int i=0;i<2;i++)
SAFE_RELEASE(PlayerAni[i]);
//关闭引擎,释放资源
Engine_Release();
return 0;
}
|