⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.c

📁 著名物理引擎Hawk的源代码
💻 C
字号:
/* demo.c, HAWK game engine
 *
 * Copyright 1997-1998 by Phil Frisbie, Jr.
 * for Hawk Software
 *
 */


#ifdef WIN32
#include <windows.h>
#endif
#include "hawk.h"
#include "demo.h"
#include "comline.h"
#include "hardware.h"

int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;

char *base1 = "maps/base1.bsp"
;
int main(int argc, char **argv)
{
	char	*map;
	int		mode = 0, texturescale;
	int		colorbits = 16; /* default setting */
	int		zbuffer = 16; /* default setting */
	float	gamma;

	/* read the command line arguments */
	initParam(argc, argv);
	if(isParam("-map"))
	{
		map = strcat("maps/", getStrParam("-map"));
	}
	else
	{
		map = base1;
	}
	if(isParam("-width"))
		w = getIntParam("-width");
	if(isParam("-height"))
		h = getIntParam("-height");
	if(isParam("-colorbits"))
	{
		colorbits = getIntParam("-colorbits");
		if((colorbits!=16)&&(colorbits!=24))
			colorbits = 16;
	}
	if(isParam("-zbuffer"))
	{
		zbuffer = getIntParam("-zbuffer");
		if((zbuffer!=16)&&(zbuffer!=24)&&(zbuffer!=32))
			zbuffer = 16;
	}
	if(isParam("-window"))
		mode |= (getIntParam("-window")? 0 : EN_FULL_SCREEN);
	else
		mode |= DEFAULT_WINDOW;
	if(isParam("-light"))
		mode |= (getIntParam("-light")? 0 : EN_LIGHT);
	else
		mode |= DEFAULT_LIGHT;
	if(isParam("-texscale"))
	{
		texturescale = getIntParam("-texscale");
		if(texturescale > 4)
			texturescale = 4;
		if(texturescale < 1)
			texturescale = 1;
		HAWK_SetTexScale(texturescale);
	}
	else
		HAWK_SetTexScale(DEFAULT_TEXSCALE);
	if(isParam("-gamma"))
	{
		gamma = getFloatParam("-gamma");
		if(gamma > 1.5)
			gamma = 1.5;
		if(gamma < 0.5)
			gamma = 0.5;
		HAWK_SetGamma(gamma);
	}
	else
		HAWK_SetGamma(1.0);
	if(isParam("-loadall"))
		mode |= (getIntParam("-window")? EN_LOAD_ALL : 0);

	HAWK_Init(w, h, mode, colorbits, zbuffer);

	if(!HAWK_LoadMap(map))
		return 1;

	HAWK_Start();

	return messageLoop();
}

#ifdef WIN32
int WINAPI WinMain (HINSTANCE instance, HINSTANCE prevInstance,
					LPSTR lpCmdLine, int cmdShow) 
{ 
	char	*argv[64], *tok; /* assume 64 max tokens */
	int		argc = 1, rval;
	char	namebuf[132];

	GetModuleFileName(NULL, namebuf, 132);

	argv[0] = namebuf;
	/* tokenize the command line */
	for (tok = strtok(lpCmdLine, " \t"); tok; tok = strtok(NULL, " \t"))
	{
		if (argc >= 64) break;
		argv[argc] = malloc(strlen(tok)+1);
		strcpy(argv[argc], tok);
		argc++;
	}

	setWindowVars(instance, prevInstance, cmdShow);

	rval = main(argc, argv);

	while(--argc)
	{
		free(argv[argc]);
	}
	return rval;
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -