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

📄 sb_bar.c

📁 使用Doom引擎开发的著名游戏《毁灭巫师》的源代码。
💻 C
📖 第 1 页 / 共 4 页
字号:
	PatchMANABRIGHT2 = W_CacheLumpName("MANABRT2", PU_STATIC);	PatchINVLFGEM1 = W_CacheLumpName("invgeml1", PU_STATIC);	PatchINVLFGEM2 = W_CacheLumpName("invgeml2", PU_STATIC);	PatchINVRTGEM1 = W_CacheLumpName("invgemr1", PU_STATIC);	PatchINVRTGEM2 = W_CacheLumpName("invgemr2", PU_STATIC);//	PatchCHAINBACK = W_CacheLumpName("CHAINBACK", PU_STATIC);	startLump = W_GetNumForName("IN0");	for(i = 0; i < 10; i++)	{		PatchINumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC);	}	PatchNEGATIVE = W_CacheLumpName("NEGNUM", PU_STATIC);	FontBNumBase = W_GetNumForName("FONTB16");	startLump = W_GetNumForName("SMALLIN0");	for(i = 0; i < 10; i++)	{		PatchSmNumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC);	}	PlayPalette = W_GetNumForName("PLAYPAL");	SpinFlylump = W_GetNumForName("SPFLY0");	SpinMinotaurLump = W_GetNumForName("SPMINO0");	SpinSpeedLump = W_GetNumForName("SPBOOT0");	SpinDefenseLump = W_GetNumForName("SPSHLD0");	for(i = 0; i < 256; i++)	{		CheatLookup[i] = CHEAT_ENCRYPT(i);	}	if(deathmatch)	{		PatchKILLS = W_CacheLumpName("KILLS", PU_STATIC);	}	SB_SetClassData();}//==========================================================================//// SB_SetClassData////==========================================================================void SB_SetClassData(void){	int class;	class = PlayerClass[consoleplayer]; // original player class (not pig)	PatchWEAPONSLOT = W_CacheLumpNum(W_GetNumForName("wpslot0")		+class, PU_STATIC);	PatchWEAPONFULL = W_CacheLumpNum(W_GetNumForName("wpfull0")		+class, PU_STATIC);	PatchPIECE1	= W_CacheLumpNum(W_GetNumForName("wpiecef1")		+class, PU_STATIC);	PatchPIECE2	= W_CacheLumpNum(W_GetNumForName("wpiecef2")		+class, PU_STATIC);	PatchPIECE3	= W_CacheLumpNum(W_GetNumForName("wpiecef3")		+class, PU_STATIC);	PatchCHAIN = W_CacheLumpNum(W_GetNumForName("chain")		+class, PU_STATIC);	if(!netgame)	{ // single player game uses red life gem (the second gem)		PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem")			+MAXPLAYERS*class+1, PU_STATIC);	}	else	{		PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem")			+MAXPLAYERS*class+consoleplayer, PU_STATIC);	}	SB_state = -1;	UpdateState |= I_FULLSCRN;}//==========================================================================//// SB_Ticker////==========================================================================void SB_Ticker(void){	int delta;	int curHealth;	curHealth = players[consoleplayer].mo->health;	if(curHealth < 0)	{		curHealth = 0;	}	if(curHealth < HealthMarker)	{		delta = (HealthMarker-curHealth)>>2;		if(delta < 1)		{			delta = 1;		}		else if(delta > 6)		{			delta = 6;		}		HealthMarker -= delta;	}	else if(curHealth > HealthMarker)	{		delta = (curHealth-HealthMarker)>>2;		if(delta < 1)		{			delta = 1;		}		else if(delta > 6)		{			delta = 6;		}		HealthMarker += delta;	}}//==========================================================================//// DrINumber//// Draws a three digit number.////==========================================================================static void DrINumber(signed int val, int x, int y){	patch_t *patch;	int oldval;	oldval = val;	if(val < 0)	{		val = -val;		if(val > 99)		{			val = 99;		}		if(val > 9)		{			patch = PatchINumbers[val/10];			V_DrawPatch(x+8, y, patch);			V_DrawPatch(x, y, PatchNEGATIVE);		}		else		{			V_DrawPatch(x+8, y, PatchNEGATIVE);		}		val = val%10;		patch = PatchINumbers[val];		V_DrawPatch(x+16, y, patch);		return;	}	if(val > 99)	{		patch = PatchINumbers[val/100];		V_DrawPatch(x, y, patch);	}	val = val%100;	if(val > 9 || oldval > 99)	{		patch = PatchINumbers[val/10];		V_DrawPatch(x+8, y, patch);	}	val = val%10;	patch = PatchINumbers[val];	V_DrawPatch(x+16, y, patch);}//==========================================================================//// DrRedINumber//// Draws a three digit number using the red font////==========================================================================static void DrRedINumber(signed int val, int x, int y){	patch_t *patch;	int oldval;	oldval = val;	if(val < 0)	{		val = 0;	}	if(val > 99)	{		patch = W_CacheLumpNum(W_GetNumForName("inred0")+val/100, PU_CACHE);		V_DrawPatch(x, y, patch);	}	val = val%100;	if(val > 9 || oldval > 99)	{		patch = W_CacheLumpNum(W_GetNumForName("inred0")+val/10, PU_CACHE);		V_DrawPatch(x+8, y, patch);	}	val = val%10;	patch = W_CacheLumpNum(W_GetNumForName("inred0")+val, PU_CACHE);	V_DrawPatch(x+16, y, patch);}//==========================================================================//// DrBNumber//// Draws a three digit number using FontB////==========================================================================static void DrBNumber(signed int val, int x, int y){	patch_t *patch;	int xpos;	int oldval;	oldval = val;	xpos = x;	if(val < 0)	{		val = 0;	}	if(val > 99)	{		patch = W_CacheLumpNum(FontBNumBase+val/100, PU_CACHE);		V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);	}	val = val%100;	xpos += 12;	if(val > 9 || oldval > 99)	{		patch = W_CacheLumpNum(FontBNumBase+val/10, PU_CACHE);		V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);	}	val = val%10;	xpos += 12;	patch = W_CacheLumpNum(FontBNumBase+val, PU_CACHE);	V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);}//==========================================================================//// DrSmallNumber//// Draws a small two digit number.////==========================================================================static void DrSmallNumber(int val, int x, int y){	patch_t *patch;	if(val <= 0)	{		return;	}	if(val > 999)	{		val %= 1000;	}	if(val > 99)	{		patch = PatchSmNumbers[val/100];		V_DrawPatch(x, y, patch);		patch = PatchSmNumbers[(val%100)/10];		V_DrawPatch(x+4, y, patch);	}	else if(val > 9)	{		patch = PatchSmNumbers[val/10];		V_DrawPatch(x+4, y, patch);	}	val %= 10;	patch = PatchSmNumbers[val];	V_DrawPatch(x+8, y, patch);}/*//==========================================================================//// ShadeLine////==========================================================================static void ShadeLine(int x, int y, int height, int shade){	byte *dest;	byte *shades;	shades = colormaps+9*256+shade*2*256;	dest = screen+y*SCREENWIDTH+x;	while(height--)	{		*(dest) = *(shades+*dest);		dest += SCREENWIDTH;	}}//==========================================================================//// ShadeChain////==========================================================================static void ShadeChain(void){	int i;	for(i = 0; i < 16; i++)	{		ShadeLine(277+i, 190, 10, i/2);		ShadeLine(19+i, 190, 10, 7-(i/2));	}}*///==========================================================================//// DrawSoundInfo//// Displays sound debugging information.////==========================================================================static void DrawSoundInfo(void){	int i;	SoundInfo_t s;	ChanInfo_t *c;	char text[32];	int x;	int y;	int xPos[7] = {1, 75, 112, 156, 200, 230, 260};	if(leveltime&16)	{		MN_DrTextA("*** SOUND DEBUG INFO ***", xPos[0], 20);	}	S_GetChannelInfo(&s);	if(s.channelCount == 0)	{		return;	}	x = 0;	MN_DrTextA("NAME", xPos[x++], 30);	MN_DrTextA("MO.T", xPos[x++], 30);	MN_DrTextA("MO.X", xPos[x++], 30);	MN_DrTextA("MO.Y", xPos[x++], 30);	MN_DrTextA("ID", xPos[x++], 30);	MN_DrTextA("PRI", xPos[x++], 30);	MN_DrTextA("DIST", xPos[x++], 30);	for(i = 0; i < s.channelCount; i++)	{		c = &s.chan[i];		x = 0;		y = 40+i*10;		if(c->mo == NULL)		{ // Channel is unused			MN_DrTextA("------", xPos[0], y);			continue;		}		sprintf(text, "%s", c->name);		M_ForceUppercase(text);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->mo->type);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->mo->x>>FRACBITS);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->mo->y>>FRACBITS);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->id);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->priority);		MN_DrTextA(text, xPos[x++], y);		sprintf(text, "%d", c->distance);		MN_DrTextA(text, xPos[x++], y);	}	UpdateState |= I_FULLSCRN;	BorderNeedRefresh = true;}//==========================================================================//// SB_Drawer////==========================================================================char patcharti[][10] ={	{ "ARTIBOX" },    	// none	{ "ARTIINVU" },   	// invulnerability	{ "ARTIPTN2" },   	// health	{ "ARTISPHL" },   	// superhealth	{ "ARTIHRAD" },		// healing radius	{ "ARTISUMN" },   	// summon maulator	{ "ARTITRCH" },   	// torch	{ "ARTIPORK" },   	// egg	{ "ARTISOAR" },   	// fly	{ "ARTIBLST" },		// blast radius	{ "ARTIPSBG" },		// poison bag	{ "ARTITELO" },		// teleport other	{ "ARTISPED" },  	// speed	{ "ARTIBMAN" },		// boost mana	{ "ARTIBRAC" },		// boost armor	{ "ARTIATLP" },   	// teleport	{ "ARTISKLL" },		// arti_puzzskull	{ "ARTIBGEM" },		// arti_puzzgembig	{ "ARTIGEMR" },		// arti_puzzgemred	{ "ARTIGEMG" },		// arti_puzzgemgreen1	{ "ARTIGMG2" },		// arti_puzzgemgreen2	{ "ARTIGEMB" },		// arti_puzzgemblue1	{ "ARTIGMB2" },		// arti_puzzgemblue2	{ "ARTIBOK1" },		// arti_puzzbook1	{ "ARTIBOK2" },		// arti_puzzbook2	{ "ARTISKL2" },		// arti_puzzskull2	{ "ARTIFWEP" },		// arti_puzzfweapon	{ "ARTICWEP" },		// arti_puzzcweapon	{ "ARTIMWEP" },		// arti_puzzmweapon	{ "ARTIGEAR" },		// arti_puzzgear1	{ "ARTIGER2" },		// arti_puzzgear2	{ "ARTIGER3" },		// arti_puzzgear3	{ "ARTIGER4" },		// arti_puzzgear4};int SB_state = -1;static int oldarti = 0;static int oldartiCount = 0;static int oldfrags = -9999;static int oldmana1 = -1;static int oldmana2 = -1;static int oldarmor = -1;static int oldhealth = -1;static int oldlife = -1;static int oldpieces = -1;static int oldweapon = -1;static int oldkeys = -1;extern boolean automapactive;void SB_Drawer(void){	// Sound info debug stuff	if(DebugSound == true)	{		DrawSoundInfo();	}	CPlayer = &players[consoleplayer];	if(viewheight == SCREENHEIGHT && !automapactive)	{		DrawFullScreenStuff();		SB_state = -1;	}	else	{		if(SB_state == -1)		{			V_DrawPatch(0, 134, PatchH2BAR);			oldhealth = -1;		}		DrawCommonBar();		if(!inventory)		{			if(SB_state != 0)			{				// Main interface				if(!automapactive)				{					V_DrawPatch(38, 162, PatchSTATBAR);				}				else				{					V_DrawPatch(38, 162, PatchKEYBAR);				}				oldarti = 0;				oldmana1 = -1;				oldmana2 = -1;				oldarmor = -1;				oldpieces = -1;				oldfrags = -9999; //can't use -1, 'cuz of negative frags				oldlife = -1;				oldweapon = -1;				oldkeys = -1;			}			if(!automapactive)			{				DrawMainBar();			}			else			{				DrawKeyBar();			}			SB_state = 0;		}		else		{			DrawInventoryBar();			SB_state = 1;		}	}	SB_PaletteFlash(false);	DrawAnimatedIcons();}//==========================================================================//// DrawAnimatedIcons////==========================================================================static void DrawAnimatedIcons(void){	int frame;	static boolean hitCenterFrame;	// Wings of wrath	if(CPlayer->powers[pw_flight])	{		if(CPlayer->powers[pw_flight] > BLINKTHRESHOLD			|| !(CPlayer->powers[pw_flight]&16))		{			frame = (leveltime/3)&15;			if(CPlayer->mo->flags2&MF2_FLY)			{				if(hitCenterFrame && (frame != 15 && frame != 0))				{					V_DrawPatch(20, 19, W_CacheLumpNum(SpinFlylump+15, 						PU_CACHE));				}				else				{					V_DrawPatch(20, 19, W_CacheLumpNum(SpinFlylump+frame, 						PU_CACHE));					hitCenterFrame = false;				}			}			else			{				if(!hitCenterFrame && (frame != 15 && frame != 0))				{					V_DrawPatch(20, 19, W_CacheLumpNum(SpinFlylump+frame, 						PU_CACHE));					hitCenterFrame = false;				}				else				{					V_DrawPatch(20, 19, W_CacheLumpNum(SpinFlylump+15, 						PU_CACHE));					hitCenterFrame = true;				}			}		}		BorderTopRefresh = true;		UpdateState |= I_MESSAGES;	}	// Speed Boots	if(CPlayer->powers[pw_speed])	{		if(CPlayer->powers[pw_speed] > BLINKTHRESHOLD

⌨️ 快捷键说明

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