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

📄 winkey.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>

//-----------------------------------------------------------------------------
const int _MAX_KEYBUFFER	=16;

int iAppendPt		=0;
int iTakePt			=0;

int iKeyAmount		=0;
int iKeyBuffer[_MAX_KEYBUFFER];
//-----------------------------------------------------------------------------
void KeyClearBuffer(void)
{
	iAppendPt		=0;
	iTakePt			=0;

	iKeyAmount		=0;
}

//-----------------------------------------------------------------------------
void KeyAppend(int iKeyPressed)
{
	if(iKeyAmount>=_MAX_KEYBUFFER) 
		return;
	else 
	{
		iKeyBuffer[iAppendPt]	=iKeyPressed;
		iAppendPt	=(iAppendPt+1)%_MAX_KEYBUFFER;
		iKeyAmount++;
		return;
	}
}

//-----------------------------------------------------------------------------
int KeyGet(void)
{	
	if(iKeyAmount==0) 
		return 0;

	int iReturnKey	=iKeyBuffer[iTakePt];
	iTakePt=(iTakePt+1)%_MAX_KEYBUFFER;
	iKeyAmount--;

	return iReturnKey;
}

//-----------------------------------------------------------------------------
bool KeyUnGet(void)
{
	if(iKeyAmount>=_MAX_KEYBUFFER) 
		return false;

	iTakePt	=(iTakePt+_MAX_KEYBUFFER-1)%_MAX_KEYBUFFER;
	iKeyAmount++;

	return true;
}

//-----------------------------------------------------------------------------

⌨️ 快捷键说明

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