`
jgsj
  • 浏览: 1001543 次
文章分类
社区版块
存档分类
最新评论

编写设定游戏按键的小程序

 
阅读更多


演示程序下载:http://download.csdn.net/detail/jiangcaiyang123/4331977

编写设定游戏按键的小程序

随着项目规模的扩大,要考虑的事情增多了。以前不用考虑的按键响应现在也觉得需要进行一番变革了。主要是看到市面上一些大中型的PC游戏都有配置程序,其中有一项功能就是设定游戏的按键。我这里挑选了一些日本C80和C81的有名游戏(《Grief Syndrome》(忧伤综合症,魔法少女小圆),《Fairy Bloom Freesia》(花精灵芙莉季娅),《妖妖剑戟梦想》)的游戏配置程序的截图。






这些小程序可以设置游戏的运行方式,以便让各种类型的显示屏、显卡、操作系统、游戏输入设备能够准确无误地工作,游戏按键的设定也是其一。配置程序将游戏的配置保存为一个文件,游戏中可以载入这些文件。其余的配置我们暂且不讨论,这里讨论的是按键的设置。

有时候我玩别人的游戏,一开始还是有些不适应的,因为游戏开发者的按键习惯不可能与用户的按键习惯完全一致,但是为了不破坏封装性,以及增添简便性,游戏开发者为用户指定了按键设定小程序,这样用户就能够很简单地设定自己喜欢的按键了。我接下来要做的就是游戏开发者做的事情。

为了减少开发的复杂度,我使用开发框架WTL来制作这个小程序。读者如果精通MFC,也可以使用MFC来制作。记得“Lion Heart”组织制作的《Sanae Challenge》(早苗的挑战)中的游戏配置就是用MFC制作的。随后要注意是否使用手柄等一些外设。如果是的话,制作这个程序就一定要用DirectInput,否则无法对游戏设备进行编程。最后
对保存的文件没有什么要求,我一般每一个键保存一个字节。

首先在主对话框CMainDlg类中添加一系列键值,以后用来保存。
	BYTE					m_Up_Key;
	BYTE					m_Down_Key;
	BYTE					m_Left_Key;
	BYTE					m_Right_Key;
	BYTE					m_Magic_Key;
	BYTE					m_SwitchMagic_Key;
	BYTE					m_Attack_Key;
	BYTE					m_Jump_Key;
	BYTE					m_Accept_Key;
	BYTE					m_Refuse_Key;

	// 手柄的按键
	BYTE					m_Up_JSKey;
	BYTE					m_Down_JSKey;
	BYTE					m_Left_JSKey;
	BYTE					m_Right_JSKey;
	BYTE					m_Magic_JSKey;
	BYTE					m_SwitchMagic_JSKey;
	BYTE					m_Attack_JSKey;
	BYTE					m_Jump_JSKey;
	BYTE					m_Accept_JSKey;
	BYTE					m_Refuse_JSKey;
	BYTE					m_nJoyStick;			// 手柄的编号

键盘最多也不会超过256个键,手柄更不会了,所以使用BYTE类型足够了。如果游戏支持多个手柄,还要保存手柄的编号,以便知道是那个手柄的按键。
初始化这些键值使用-1就行了,像这样:
	CMainDlg( void )
	{		
		m_Up_Key					= -1;
		m_Down_Key					= -1;
		m_Left_Key					= -1;
		m_Right_Key					= -1;
		m_Magic_Key					= -1;
		m_SwitchMagic_Key			= -1;
		m_Attack_Key				= -1;
		m_Jump_Key					= -1;
		m_Accept_Key				= -1;
		m_Refuse_Key				= -1;


		m_Up_JSKey					= -1;
		m_Down_JSKey				= -1;
		m_Left_JSKey				= -1;
		m_Right_JSKey				= -1;
		m_Magic_JSKey				= -1;
		m_SwitchMagic_JSKey			= -1;
		m_Attack_JSKey				= -1;
		m_Jump_JSKey				= -1;
		m_Accept_JSKey				= -1;
		m_Refuse_JSKey				= -1;
	}
	
	CMainDlg中的OnIdle( )函数是每次渲染对话框的时候会调用,而对按键的检测是在每帧中调用的,所以我们可以将按键检测的代码放在这里,下面是伪代码:
	
	virtual BOOL OnIdle()
	{
		if ( 需要记录按键 )
		{
			if ( 需要记录键盘的按键 )
			{
				记录键盘的按键
			}
			else if ( 需要记录手柄的按键 )
			{
				记录手柄的按键
			}
		}
	}

dinput.h 文件只是对按键使用了#define定义,其实是一些BYTE数字,要是让开发者看到了,他们肯定记不住,更别说用户了,他们更看不懂。所以我必须设置一个数组,它看起来像这样:

const tchar g_KeyMap[256][15] = 
{
	tr( "无效" ),
	tr( "Esc" ),
	tr( "1" ),
	tr( "2" ),
	tr( "3" ),
	tr( "4" ),
	tr( "5" ),
	tr( "6" ),
	tr( "7" ),
	tr( "8" ),
	tr( "9" ),
	tr( "0" ),
	tr( "-" ),		// 主键盘上
	tr( "=" ),
	tr( "Backspace" ),
	tr( "Tab" ),
	tr( "Q" ),
	tr( "W" ),
	tr( "E" ),
	tr( "R" ),
	tr( "T" ),
	tr( "Y" ),
	tr( "U" ),
	tr( "I" ),
	tr( "O" ),
	tr( "P" ),
	tr( "[" ),
	tr( "]" ),
	tr( "Enter" ),
	tr( "L-Ctrl" ),
	tr( "A" ),
	tr( "S" ),
	tr( "D" ),
	tr( "F" ),
	tr( "G" ),
	tr( "H" ),
	tr( "J" ),
	tr( "K" ),
	tr( "L" ),
	tr( ";" ),
	tr( "'" ),
	tr( "`" ),
	tr( "L-Shift" ),
	tr( "\\" ),
	tr( "Z" ),
	tr( "X" ),
	tr( "C" ),
	tr( "V" ),
	tr( "B" ),
	tr( "N" ),
	tr( "M" ),
	tr( "," ),
	tr( "." ),
	tr( "/" ),
	tr( "R-Shift" ),
	tr( "*" ),
	tr( "L-Alt" ),
	tr( "Space" ),
	tr( "Caps Lock" ),
	tr( "F1" ),
	tr( "F2" ),
	tr( "F3" ),
	tr( "F4" ),
	tr( "F5" ),
	tr( "F6" ),
	tr( "F7" ),
	tr( "F8" ),
	tr( "F9" ),
	tr( "F10" ),
	tr( "Num Lock" ),
	tr( "Scroll Lock" ),
	tr( "7" ),
	tr( "8" ),
	tr( "9" ),
	tr( "-" ),
	tr( "4" ),
	tr( "5" ),
	tr( "6" ),
	tr( "+" ),
	tr( "1" ),
	tr( "2" ),
	tr( "3" ),
	tr( "0" ),
	tr( "." ),				// 0x53
	tr( "无效" ),
	tr( "无效" ),
	tr( "OEM-102" ),
	tr( "F11" ),
	tr( "F12" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "F13" ),
	tr( "F14" ),
	tr( "F15" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Kana" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Abnt-C1" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Convert" ),
	tr( "无效" ),
	tr( "NoConvert" ),
	tr( "无效" ),
	tr( "Yen" ),
	tr( "Abnt-C2" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "=" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "PreTrack" ),
	tr( "At" ),
	tr( "Colon" ),
	tr( "_" ),
	tr( "Kanji" ),
	tr( "Stop" ),
	tr( "Ax" ),
	tr( "Unlabeled" ),
	tr( "无效" ),
	tr( "NextTrack" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Enter" ),
	tr( "R-Control" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Mute" ),
	tr( "Calculator" ),
	tr( "Play/Pause" ),
	tr( "无效" ),
	tr( "MediaStop" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Vol-" ),
	tr( "无效" ),
	tr( "Vol+" ),
	tr( "无效" ),
	tr( "WebHome" ),
	tr( "," ),
	tr( "无效" ),
	tr( "/" ),
	tr( "无效" ),
	tr( "SysRq" ),
	tr( "R-Alt" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Pause" ),
	tr( "无效" ),
	tr( "Home" ),
	tr( "↑" ),
	tr( "PageUp" ),
	tr( "无效" ),
	tr( "←" ),
	tr( "无效" ),
	tr( "→" ),
	tr( "无效" ),
	tr( "End" ),
	tr( "↓" ),
	tr( "PageDn" ),
	tr( "Delete" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "L-Windows" ),
	tr( "R-Windows" ),
	tr( "Apps" ),
	tr( "Power" ),
	tr( "Sleep" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "Wake" ),
	tr( "无效" ),
	tr( "WebSearch" ),
	tr( "WebFavorites" ),
	tr( "WebRefresh" ),
	tr( "WebStop" ),
	tr( "WebForward" ),
	tr( "WebBack" ),
	tr( "MyComputer" ),
	tr( "Mail" ),
	tr( "MediaSelect" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "?" ),
};


const tchar g_JSKeyMap[256][15] =
{
	tr( "1" ),
	tr( "2" ),
	tr( "3" ),
	tr( "4" ),
	tr( "5" ),
	tr( "6" ),
	tr( "7" ),
	tr( "8" ),
	tr( "9" ),
	tr( "10" ),
	tr( "11" ),
	tr( "12" ),
	tr( "13" ),
	tr( "14" ),
	tr( "15" ),
	tr( "16" ),
	tr( "17" ),
	tr( "18" ),
	tr( "19" ),
	tr( "20" ),
	tr( "无效" ),				// 现在无法用到
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "↑" ),
	tr( "↓" ),
	tr( "←" ),
	tr( "→" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "无效" ),
	tr( "?" ),
};
这样映射DIK_宏,显示出来的是一系列按键,用户就能够看得懂了。最后需要保存,可以在OnOK( )函数中进行设置。保存部分的代码如下所示:

	bool SaveKeyConfigToFile( void )
	{
		FILE* pFile;
		pFile = fopen( m_ConfigFileName, "wb" );
		if ( pFile == 0 ) return false;
		
		// 写入数值
		fwrite( &m_Up_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Down_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Left_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Right_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Magic_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_SwitchMagic_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Attack_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Jump_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Accept_Key, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Refuse_Key, sizeof( BYTE ), 1, pFile );


		fwrite( &m_nJoyStick, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Up_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Down_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Left_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Right_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Magic_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_SwitchMagic_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Attack_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Jump_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Accept_JSKey, sizeof( BYTE ), 1, pFile );
		fwrite( &m_Refuse_JSKey, sizeof( BYTE ), 1, pFile );


		fclose( pFile );	
		return true;
	}
读取配置文件的步骤与此类似,这里不再赘述。

既然对游戏的按键进行了设置,那么就应该在主程序中使用这些预定义的游戏的按键了。我认为一个游戏控制系统至少具备以下几个函数:
	bool InitGameInput( void );				// 初始化游戏的输入
	bool DeleteGameInput( void );			// 删除游戏的输入
	void UpdateKeyState( void );			// 更新游戏的输入
	void ReadKeyConfigFromFile( const char* fileName );		// 读取游戏输入的配置文件

同时为了对游戏中的按键是否按下进行判断,决定定义以下这些函数:
	bool Up_KeyDown( void );
	bool Down_KeyDown( void );
	bool Left_KeyDown( void );
	bool Right_KeyDown( void );
	bool Magic_KeyDown( void );
	bool SwitchMagic_KeyDown( void );
	bool Attack_KeyDown( void );
	bool Jump_KeyDown( void );
	bool Accept_KeyDown( void );
	bool Refuse_KeyDown( void );

这些函数的实现就不再向大家介绍了。
分享到:
评论

相关推荐

    设定游戏按键小程序(演示程序)

    编写设定游戏按键的小程序 随着项目规模的扩大,要考虑的事情增多了。以前不用考虑的按键响应现在也觉得需要进行一番变革了。主要是看到市面上一些大中型的PC游戏都有配置程序,其中有一项功能就是设定游戏的按键。...

    MTK小程序 有按键操作 绘制

    "有按键操作"意味着这个小程序支持用户通过设备上的按键来触发各种功能。这可能包括启动、暂停、停止、退出等操作。开发者需要编写对应的按键事件处理函数,当用户按下特定键时,程序会做出相应的响应。 接下来是...

    单片机按键控制程序【C语言】.zip_单片机按键控制

    在这个主题中,我们有三个不同的C语言程序用于单片机的按键控制,分别是“按键键状态显示程序【C语言版2】”、“按键键状态消抖程序【C语言版1】”和“按键移位程序【C语言版】”。这些程序提供了多种方法来处理...

    51单片机矩阵按键简洁程序加图

    在实际编写程序时,需要注意以下几点: 1. 使用循环或中断进行按键扫描,确保及时响应按键操作。 2. 为了防止按键抖动导致误识别,通常会加入去抖动处理,如延时或两次扫描比较。 3. 数码管的显示代码应考虑段码表的...

    汇编语言编写的小程序

    汇编语言编写的小程序通常用于实现特定的、高效的任务,因为它们可以直接控制硬件资源,对于需要精确控制计算过程的应用非常有用。在这个场景中,我们讨论的是一个用汇编语言编写的特定类型的小程序,它包含了两个...

    vb编写的简单小程序3

    标题中的“vb编写的简单小程序3”表明这是一个关于Visual Basic(VB)编程的集合,包含多个小型应用程序。VB是一种基于事件驱动的编程语言,由微软开发,常用于创建Windows桌面应用。这些小程序可能涵盖各种实用功能...

    AVR 按键汇编程序

    在AVR上编写按键扫描程序,通常会使用定时器来定期检测按键状态。定时器是一个硬件模块,可以周期性地产生中断,从而提供了一种在特定时间间隔内执行代码的方式。例如,我们可以设置一个定时器,每隔一定毫秒就中断...

    单片机按键实现的程序

    单片机按键实现的程序是单片机编程中常见的任务之一,主要涉及到硬件接口设计、中断处理、软件消抖以及状态机的设计等多...掌握这些知识,不仅可以编写出稳定的按键处理程序,也为后续更复杂的单片机应用打下坚实基础。

    51单片机按键扫描C程序

    例如,你可以定义一个全局变量来存储上次按键状态,中断服务程序中比较当前状态与上一次状态,若发生变化且在设定时间内状态稳定,则认为按键动作有效。 总结来说,51单片机通过定时器进行按键扫描是一种高效且能...

    STM32 按键程序.rar

    以上内容涵盖了STM32微控制器在实现按键功能时涉及的关键知识点,通过理解这些概念,开发者可以编写出高效且稳定的按键程序。在具体实践中,还需要根据项目需求和硬件环境进行适当的调整和优化。

    学习游戏脚本制作:按键精灵键鼠同步器源码分享.pdf

    学习游戏脚本制作:按键精灵键鼠同步器源码分享 本文主要讲解了学习游戏脚本制作中的按键精灵键鼠同步器的实现原理和具体实现步骤。按键精灵键鼠同步器是游戏同步的重要组件,它可以实现在两个窗口之间的键鼠同步。...

    51单片机--按键防抖代码

    在51单片机中,通常采用软件方法,即在检测到按键按下后等待一小段时间(如20-50毫秒),然后再检查一次按键状态,如果状态保持不变,则认为按键真正被按下或释放。这种方法称为“两次采样法”。 在中断处理方面,...

    vc++ 编写的绘制矩形的小程序

    在这个小程序中,API函数如`CreateWindow`用于创建窗口,`SetWindowLong`用于设置窗口过程,`GetMessage`和`DispatchMessage`用于处理消息循环。 2. **MFC(Microsoft Foundation Classes)框架**:MFC是微软为简化...

    C# 编写小程序 读心术

    【C# 编写小程序 读心术】 在IT领域,C#是一种广泛使用的编程语言,尤其在开发Windows应用程序和游戏时。本项目名为“读心术”,它是一个利用C#编写的小程序,旨在创建一个有趣的效果,让用户感觉程序能够读取他们...

    OK6410按键控制LED灯程序

    在本文中,我们将深入探讨如何使用OK6410微控制器进行按键控制LED灯的程序设计,这是一项常见的嵌入式系统应用。OK6410是一款基于ARM7内核的低成本、高性能微处理器,广泛应用于各种嵌入式系统设计中,如智能家居、...

    VB.NET编写的贪吃蛇小游戏代码

    本项目是使用VB.NET编写的贪吃蛇小游戏,这是一款经典的像素级游戏,玩家需要控制蛇在有限的区域内移动,吃掉食物以增长蛇的身体长度,同时避免蛇头碰到自身或边界,否则游戏结束。 在VB.NET中,贪吃蛇游戏的实现...

    S3C2410按键测试程序

    本文将深入探讨如何为S3C2410编写一个有效的按键扫描程序,以帮助初学者理解并掌握这一关键技能。 首先,我们需要了解S3C2410的GPIO工作模式。在按键应用中,通常将按键连接到S3C2410的GPIO引脚,配置为输入模式。...

    按键左右移位led源程序

    对于这个项目,程序员需要定义好LED灯的输出端口,设置初始化程序,然后编写主循环来处理按键输入和LED移位逻辑。在按键处理部分,可能需要引入延时函数来滤除按键抖动,确保稳定可靠的按键识别。在LED移位部分,...

    简单的贪吃蛇程序,c语言编写

    此C语言编写的贪吃蛇程序提供了一个基础的游戏框架,适合初学者学习C语言编程的同时了解基本的游戏开发流程。通过分析代码结构、游戏逻辑等,不仅可以帮助初学者快速上手,还能为后续更复杂的游戏项目打下坚实的基础...

    字符变色小程序,支持8个按键!

    标题中的“字符变色小程序,支持8个按键!”揭示了一个基于字符界面的程序,它具有颜色变换的功能。这个小程序设计简单而有趣,用户可以通过8个预定义的按键来改变屏幕上字符的颜色,从而实现视觉效果的变化。 1. *...

Global site tag (gtag.js) - Google Analytics