开源项目之开源的2D游戏引擎 HGE

HGE游戏引擎是一个基于directX的游戏引擎,它的渲染及逻辑是基于帧回调的框架模式,其提供一些基本的图像操作和输入控制功能。

项目如图:



fontconv测试代码(参数二:文件路径):

int main(int argc, char* argv[])
{
	HANDLE				hSearch;
	WIN32_FIND_DATA		SearchData;
	int					nfiles=0;
	bool				done=false;
	char				*buf, filename[256];
	filelist			*newFile, *nextFile;

	printf("\nHGE Font 1.XX -> 1.6 converter\nCopyright (C) 2003-2006, Relish Games\n\n");
	
	if(argc!=2)
	{
		printf("Usage: FONTCONV.EXE <wildcard>\n\n");
		printf("All files found by the specified wildcard will\n");
		printf("be automatically converted to newer format. Bitmap files\n");
		printf("should be available along with font description files.\n\n");
		return 0;
	}
	else
	{
		hSearch=FindFirstFile(argv[1], &SearchData);
		nextFile=0;

		for(;;)
		{
			if(hSearch==INVALID_HANDLE_VALUE || done)
			{
				FindClose(hSearch);
				break;
			}

			if(!(SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				strcpy(filename, argv[1]);
				buf=strrchr(filename, '\\');
				if(!buf) buf=filename; else buf++;
				strcpy(buf,SearchData.cFileName);
				newFile=new filelist;
				strcpy(newFile->filename,filename);
				newFile->next=0;
				if(nextFile) nextFile->next=newFile;
				else files=newFile;
				nextFile=newFile;
			}

			done=!FindNextFile(hSearch, &SearchData);
		}

		hge=hgeCreate(HGE_VERSION);
		hge->System_SetState(HGE_USESOUND, false);
		hge->System_SetState(HGE_WINDOWED, true);
		hge->System_SetState(HGE_SCREENWIDTH, 640);
		hge->System_SetState(HGE_SCREENHEIGHT, 480);

		if(!hge->System_Initiate())
		{
			hge->Release();
			printf("\nCan't initiate HGE.\n\n",nfiles);
			return 0;
		}

		newFile=files;
		while(newFile)
		{
			if(convert(newFile->filename)) nfiles++;
			nextFile=newFile->next;
			delete newFile;
			newFile=nextFile;
		}

		hge->System_Shutdown();
		hge->Release();
		printf("\n%d file(s) successfully converted.\n\n",nfiles);
		return 0;
	}
}

效果如图:



fonted测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_INIFILE, "fonted.ini");
	hge->System_SetState(HGE_LOGFILE, "fonted.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Bitmap Font Builder");
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);
	hge->System_SetState(HGE_USESOUND, false);

	if(hge->Ini_GetInt("HGE", "FullScreen",0))	hge->System_SetState(HGE_WINDOWED, false);
	else hge->System_SetState(HGE_WINDOWED, true);

	if(hge->System_Initiate())
	{
		InitEditor();
		hge->System_Start();
		DoneEditor();
	}
	else MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_TASKMODAL);

	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图:



hge 和hgehelp是引擎动态库!~

particleed测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_INIFILE, "particleed.ini");
	hge->System_SetState(HGE_LOGFILE, "particleed.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Particle Systems Editor");
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);
	hge->System_SetState(HGE_USESOUND, false);

	if(hge->Ini_GetInt("HGE", "FullScreen",0))	hge->System_SetState(HGE_WINDOWED, false);
	else hge->System_SetState(HGE_WINDOWED, true);

	if(hge->System_Initiate())
	{
		InitEditor();
		hge->System_Start();
		DoneEditor();
	}
	else MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);

	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图:



pngopt测试代码:

int main(int argc, char* argv[])
{
	HANDLE				hSearch;
	WIN32_FIND_DATA		SearchData;
	int					nfiles=0;
	bool				done=false;
	char				*buf, filename[256];
	filelist			*newFile, *nextFile;

	printf("\nPNG Optimizer v0.2\nCopyright (C) 2003-2008, Relish Games\n\n");
	
	if(argc!=2)
	{
		printf("Usage: PNGOPT.EXE <wildcard>\n\n");
		printf("The image data of all files found by the specified wildcard\n");
		printf("will be expanded beneath the alpha channel boundary.\n");
		printf("So images will render without artifacts when scaled, stretched,\n");
		printf("rotated or rendered into not integer coordinates.\n\n");
		return 0;
	}
	else
	{
		hSearch=FindFirstFile(argv[1], &SearchData);
		nextFile=0;

		for(;;)
		{
			if(hSearch==INVALID_HANDLE_VALUE || done)
			{
				FindClose(hSearch);
				break;
			}

			if(!(SearchData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				strcpy(filename, argv[1]);
				buf=strrchr(filename, '\\');
				if(!buf) buf=filename; else buf++;
				strcpy(buf,SearchData.cFileName);
				newFile=new filelist;
				strcpy(newFile->filename,filename);
				newFile->next=0;
				if(nextFile) nextFile->next=newFile;
				else files=newFile;
				nextFile=newFile;
			}

			done=!FindNextFile(hSearch, &SearchData);
		}

		hge=hgeCreate(HGE_VERSION);
		hge->System_SetState(HGE_USESOUND, false);
		hge->System_SetState(HGE_WINDOWED, true);
		hge->System_SetState(HGE_SCREENWIDTH, 320);
		hge->System_SetState(HGE_SCREENHEIGHT, 200);
		hge->System_SetState(HGE_SHOWSPLASH, false);

		if(!hge->System_Initiate())
		{
			hge->Release();
			printf("\nCan't initiate HGE.\n\n",nfiles);
			return 0;
		}

		newFile=files;
		while(newFile)
		{
			if(convert(newFile->filename)) nfiles++;
			nextFile=newFile->next;
			delete newFile;
			newFile=nextFile;
		}

		hge->System_Shutdown();
		hge->Release();
		printf("\n%d image(s) successfully optimized.\n\n",nfiles);
		return 0;
	}
}

效果如图(没有参数):



hge_tut01测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	// Here we use global pointer to HGE interface.
	// Instead you may use hgeCreate() every
	// time you need access to HGE. Just be sure to
	// have a corresponding hge->Release()
	// for each call to hgeCreate()
	hge = hgeCreate(HGE_VERSION);

	// Set our frame function
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);

	// Set the window title
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 01 - Minimal HGE application");
	
	// Run in windowed mode
	// Default window size is 800x600
	hge->System_SetState(HGE_WINDOWED, true);

	// Don't use BASS for sound
	hge->System_SetState(HGE_USESOUND, false);

	// Tries to initiate HGE with the states set.
	// If something goes wrong, "false" is returned
	// and more specific description of what have
	// happened can be read with System_GetErrorMessage().
	if(hge->System_Initiate())
	{
		// Starts running FrameFunc().
		// Note that the execution "stops" here
		// until "true" is returned from FrameFunc().
		hge->System_Start();
	}
	else
	{	
		// If HGE initialization failed show error message
		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.

	// Restore video mode and free
	// all allocated resources
	hge->System_Shutdown();

	// Release the HGE interface.
	// If there are no more references,
	// the HGE object will be deleted.
	hge->Release();

	return 0;
}

效果:



hge_tut02测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	// Get HGE interface
	hge = hgeCreate(HGE_VERSION);

	// Set up log file, frame function, render function and window title
	hge->System_SetState(HGE_LOGFILE, "hge_tut02.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 02 - Using input, sound and rendering");

	// Set up video mode
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);

	if(hge->System_Initiate())
	{
		// Load sound and texture
		snd=hge->Effect_Load("menu.wav");
		quad.tex=hge->Texture_Load("particles.png");
		if(!snd || !quad.tex)
		{
			// If one of the data files is not found, display
			// an error message and shutdown.
			MessageBox(NULL, "Can't load MENU.WAV or PARTICLES.PNG", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		// Set up quad which we will use for rendering sprite
		quad.blend=BLEND_ALPHAADD | BLEND_COLORMUL | BLEND_ZWRITE;

		for(int i=0;i<4;i++)
		{
			// Set up z-coordinate of vertices
			quad.v[i].z=0.5f;
			// Set up color. The format of DWORD col is 0xAARRGGBB
			quad.v[i].col=0xFFFFA000;
		}

		// Set up quad's texture coordinates.
		// 0,0 means top left corner and 1,1 -
		// bottom right corner of the texture.
		quad.v[0].tx=96.0/128.0; quad.v[0].ty=64.0/128.0; 
		quad.v[1].tx=128.0/128.0; quad.v[1].ty=64.0/128.0; 
		quad.v[2].tx=128.0/128.0; quad.v[2].ty=96.0/128.0; 
		quad.v[3].tx=96.0/128.0; quad.v[3].ty=96.0/128.0; 

		// Let's rock now!
		hge->System_Start();

		// Free loaded texture and sound
		hge->Texture_Free(quad.tex);
		hge->Effect_Free(snd);
	}
	else MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);

	// Clean up and shutdown
	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图(鼠标可以操作中间的圈圈):



hge_tut03测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_LOGFILE, "hge_tut03.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 03 - Using helper classes");
	hge->System_SetState(HGE_FPS, 100);
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);

	if(hge->System_Initiate()) {

		// Load sound and texture
		snd=hge->Effect_Load("menu.wav");
		tex=hge->Texture_Load("particles.png");
		if(!snd || !tex)
		{
			// If one of the data files is not found, display
			// an error message and shutdown.
			MessageBox(NULL, "Can't load one of the following files:\nMENU.WAV, PARTICLES.PNG, FONT1.FNT, FONT1.PNG, TRAIL.PSI", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		// Create and set up a sprite
		spr=new hgeSprite(tex, 96, 64, 32, 32);
		spr->SetColor(0xFFFFA000);
		spr->SetHotSpot(16,16);

		// Load a font
		fnt=new hgeFont("font1.fnt");

		// Create and set up a particle system
		spt=new hgeSprite(tex, 32, 32, 32, 32);
		spt->SetBlendMode(BLEND_COLORMUL | BLEND_ALPHAADD | BLEND_NOZWRITE);
		spt->SetHotSpot(16,16);
		par=new hgeParticleSystem("trail.psi",spt);
		par->Fire();

		// Let's rock now!
		hge->System_Start();

		// Delete created objects and free loaded resources
		delete par;
		delete fnt;
		delete spt;
		delete spr;
		hge->Texture_Free(tex);
		hge->Effect_Free(snd);
	}

	// Clean up and shutdown
	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图(影艳):



hge_tut04测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_LOGFILE, "hge_tut04.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_GFXRESTOREFUNC, GfxRestoreFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 04 - Using render targets");
	hge->System_SetState(HGE_FPS, 100);
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);

	tar=0;
	target=0;

	if(hge->System_Initiate()) {
		snd=hge->Effect_Load("menu.wav");
		tex=hge->Texture_Load("particles.png");
		if(!snd || !tex)
		{
			// If one of the data files is not found, display
			// an error message and shutdown.
			MessageBox(NULL, "Can't load one of the following files:\nMENU.WAV, PARTICLES.PNG, FONT1.FNT, FONT1.PNG, TRAIL.PSI", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		spr=new hgeSprite(tex, 96, 64, 32, 32);
		spr->SetColor(0xFFFFA000);
		spr->SetHotSpot(16,16);

		fnt=new hgeFont("font1.fnt");

		spt=new hgeSprite(tex, 32, 32, 32, 32);
		spt->SetBlendMode(BLEND_COLORMUL | BLEND_ALPHAADD | BLEND_NOZWRITE);
		spt->SetHotSpot(16,16);
		par=new hgeParticleSystem("trail.psi",spt);
		par->Fire();

		// Create a render target and a sprite for it
		target=hge->Target_Create(512,512,false);
		tar=new hgeSprite(hge->Target_GetTexture(target),0,0,512,512);
		tar->SetBlendMode(BLEND_COLORMUL | BLEND_ALPHAADD | BLEND_NOZWRITE);

		// Let's rock now!
		hge->System_Start();

		// Delete created objects and free loaded resources
		delete par;
		delete fnt;
		delete spt;
		delete spr;
		delete tar;
		hge->Target_Free(target);
		hge->Texture_Free(tex);
		hge->Effect_Free(snd);
	}

	// Clean up and shutdown
	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图:



hge_tut05测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_LOGFILE, "hge_tut05.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 05 - Using distortion mesh");
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);
	hge->System_SetState(HGE_USESOUND, false);

	if(hge->System_Initiate()) {

		// Load sound and texture
		tex=hge->Texture_Load("texture.jpg");
		if(!tex)
		{
			// If one of the data files is not found, display
			// an error message and shutdown.
			MessageBox(NULL, "Can't load TEXTURE.JPG", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		// Create a distortion mesh
		dis=new hgeDistortionMesh(nCols, nRows);
		dis->SetTexture(tex);
		dis->SetTextureRect(0,0,512,512);
		dis->SetBlendMode(BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_ZWRITE);
		dis->Clear(0xFF000000);

		// Load a font
		fnt=new hgeFont("font1.fnt");

		// Let's rock now!
		hge->System_Start();

		// Delete created objects and free loaded resources
		delete fnt;
		delete dis;
		hge->Texture_Free(tex);
	}

	// Clean up and shutdown
	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图(图片有波动):



hge_tut06测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	hge->System_SetState(HGE_LOGFILE, "hge_tut06.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 06 - Creating menus");
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, 800);
	hge->System_SetState(HGE_SCREENHEIGHT, 600);
	hge->System_SetState(HGE_SCREENBPP, 32);

	if(hge->System_Initiate())
	{

		// Load sound and textures
		quad.tex=hge->Texture_Load("bg.png");
		tex=hge->Texture_Load("cursor.png");
		snd=hge->Effect_Load("menu.wav");
		if(!quad.tex || !tex || !snd)
		{
			// If one of the data files is not found, display
			// an error message and shutdown.
			MessageBox(NULL, "Can't load BG.PNG, CURSOR.PNG or MENU.WAV", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		// Set up the quad we will use for background animation
		quad.blend=BLEND_ALPHABLEND | BLEND_COLORMUL | BLEND_NOZWRITE;

		for(int i=0;i<4;i++)
		{
			// Set up z-coordinate of vertices
			quad.v[i].z=0.5f;
			// Set up color. The format of DWORD col is 0xAARRGGBB
			quad.v[i].col=0xFFFFFFFF;
		}

		quad.v[0].x=0; quad.v[0].y=0; 
		quad.v[1].x=800; quad.v[1].y=0; 
		quad.v[2].x=800; quad.v[2].y=600; 
		quad.v[3].x=0; quad.v[3].y=600; 


		// Load the font, create the cursor sprite
		fnt=new hgeFont("font1.fnt");
		spr=new hgeSprite(tex,0,0,32,32);

		// Create and initialize the GUI
		gui=new hgeGUI();

		gui->AddCtrl(new hgeGUIMenuItem(1,fnt,snd,400,200,0.0f,"Play"));
		gui->AddCtrl(new hgeGUIMenuItem(2,fnt,snd,400,240,0.1f,"Options"));
		gui->AddCtrl(new hgeGUIMenuItem(3,fnt,snd,400,280,0.2f,"Instructions"));
		gui->AddCtrl(new hgeGUIMenuItem(4,fnt,snd,400,320,0.3f,"Credits"));
		gui->AddCtrl(new hgeGUIMenuItem(5,fnt,snd,400,360,0.4f,"Exit"));

		gui->SetNavMode(HGEGUI_UPDOWN | HGEGUI_CYCLED);
		gui->SetCursor(spr);
		gui->SetFocus(1);
		gui->Enter();

		// Let's rock now!
		hge->System_Start();

		// Delete created objects and free loaded resources
		delete gui;
		delete fnt;
		delete spr;
		hge->Effect_Free(snd);
		hge->Texture_Free(tex);
		hge->Texture_Free(quad.tex);
	}

	// Clean up and shutdown
	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图:



hge_tut07测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	int i;

	hge = hgeCreate(HGE_VERSION);

	// Set desired system states and initialize HGE

	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);

	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 0;
		}

		// 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(i=0;i<MAX_OBJECTS;i++)
		{
			pObjects[i].x=hge->Random_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();
	return 0;
}

效果如图:



hge_tut08测试代码:

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	hge = hgeCreate(HGE_VERSION);

	// Set desired system states and initialize HGE

	hge->System_SetState(HGE_LOGFILE, "hge_tut08.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "HGE Tutorial 08 - The Big Calm");
	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);

	if(hge->System_Initiate())
	{
		fnt=new hgeFont("font2.fnt");
		
		if(!InitSimulation())
		{
			// If one of the data files is not found, display an error message and shutdown
			MessageBox(NULL, "Can't load resources. See log for details.", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		hge->System_Start();

		DoneSimulation();
		delete fnt;
	}

	hge->System_Shutdown();
	hge->Release();
	return 0;
}

效果如图:


学习的目标是成熟!~~~~















  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
基本功能和翎风的一样。 ------------------------------------------------------------------ [2016.09.30] 更新M2功能 ------------------------------------------------------------------ 1.增加脚本命令:InSafeZone //检测人物是否在安全区 ------------------------------------------------------------------ 2.修改程序防止最新僵尸攻击 3.增加脚本命令:SETRANDOMNO //产生一个随机数字 [@main] #IF #ACT SETRANDOMNO //产生一个随机数字 #SAY : //将显示出产生的随机数 [@@CHECKNO] #IF CHECKRANDOMNO //检测输入的验证码是否正确 #ELSEACT MESSAGEBOX 验证码错误! CLOSE BREAK 4.增加脚本命令:ISONMAP MAP //检测当前人是否在MAP地图上 5.增加脚本命令:DELAYCALL 作用:延时执行同一个NPC脚本中指定的标签内容 格式:DELAYCALL S LABEL 其中S是延时秒数(毫秒),Label是执行的脚本标签 示例:DelayCall 3000 @DELAYCALLTEST --- 3秒后自动跳到@DELAYCALLTEST节执行 6.增加脚本命令:KILLBYMON //是否被怪杀 7.增加脚本命令:KILLBYHUM //是否被人杀 地图增加一参数:KILLFUNC(X) //X可以随意数字 说明: 人物在该地图杀人,将触发QFunction-0.txt的[@KillPlay数字]节 人物在该地图杀怪,将触发QFunction-0.txt的[@KillPlayMon数字]节 注:宝宝杀人杀怪有效(秒杀除外) 8. //杀人的怪物名字 9. //杀人的人物名字 #IF KILLBYMON SENDMSG 5 在:%m(%x:%y)把干掉了! #IF KILLBYHUM SENDMSG 5 在:%m(%x:%y)把干掉了! 10.增加人物S变量:(0~99个) 11.解决地图标记 NoHUMNoMon 有人刷怪不能用的问题! 12.增加NPC命令:REPAIRALL //特修身上所有装备 13.增加数据库(修复神水)设置:3 14 //特修身上所有装备 14.增加脚本命令:ISGROUPMASTER //检测是否组长,加入编组后组长会触发QFunction-0.txt 15.增加挂机泡点功能。 ===================================== OFFLINE S EXP S是时间,单位秒 EXP为每S秒得到的经验值 默认必须在安全区域有效 脚本示意: (******************************************************************) (@@offlinemsg) [@main] 一、点击开始脱机泡点后,可输入一段留言信息给你的朋友。\ \ \ \ [@@offlinemsg] #IF CHECKLEVEL > 0 #ACT OFFLINE 5 500 //每5秒增加500经验 --------------------------------------------------------------------------- 16.;检测是否组长 [@MAIN] #IF ISGROUPMASTER #ACT GroupMoveMap 3 330 330 #elsesay 你不是组长. 加入编组后组长会触发QFunction-0.txt [@GroupCreate] #if #say 加入编组 --------------------------------------------------------------------------- 17.增加脱机泡点功能 18.增加地图标记有人刷怪 [0 比奇] NoHUMNoMon ;有人才开始刷怪 19.增加地图标记禁止仍背包物品 [1 沃玛森林] NOTHROWITEM ;禁止仍背包物品 20.增加地图标记死后不爆背包物品 [2 毒蛇山谷] NODR

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值