优化按键处理逻辑,增加按键得分功能并清理代码
This commit is contained in:
parent
9b3363ec35
commit
ec850cd1d6
|
@ -221,7 +221,7 @@ public class MusicFrom
|
|||
{
|
||||
|
||||
// 创建一个字典来跟踪每个按键的前一次状态
|
||||
var keyStates = new System.Collections.Generic.Dictionary<int, bool>
|
||||
var keyStates = new Dictionary<int, bool>
|
||||
{
|
||||
{ VK_D, false },
|
||||
{ VK_F, false },
|
||||
|
@ -306,10 +306,18 @@ public class MusicFrom
|
|||
case VK_F:
|
||||
isDown[1] = true;
|
||||
// 处理F键被按下的逻辑
|
||||
if (Program.chars[8, 10].Char == 'F' || Program.chars[9, 10].Char == 'F')
|
||||
{
|
||||
score += 100;
|
||||
}
|
||||
break;
|
||||
case VK_G:
|
||||
isDown[2] = true;
|
||||
// 处理G键被按下的逻辑
|
||||
if (Program.chars[8, 17].Char == 'G' || Program.chars[9, 17].Char == 'G')
|
||||
{
|
||||
score += 100;
|
||||
}
|
||||
break;
|
||||
case VK_SPACE:
|
||||
isDown[3] = true;
|
||||
|
@ -318,14 +326,26 @@ public class MusicFrom
|
|||
case VK_J:
|
||||
isDown[4] = true;
|
||||
// 处理J键被按下的逻辑
|
||||
if (Program.chars[8, 31].Char == 'J' || Program.chars[9, 31].Char == 'J')
|
||||
{
|
||||
score += 100;
|
||||
}
|
||||
break;
|
||||
case VK_K:
|
||||
isDown[5] = true;
|
||||
// 处理K键被按下的逻辑
|
||||
if (Program.chars[8, 38].Char == 'K' || Program.chars[9, 38].Char == 'K')
|
||||
{
|
||||
score += 100;
|
||||
}
|
||||
break;
|
||||
case VK_L:
|
||||
isDown[6] = true;
|
||||
// 处理L键被按下的逻辑
|
||||
if (Program.chars[8, 45].Char == 'L' || Program.chars[9, 45].Char == 'L')
|
||||
{
|
||||
score += 100;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using Debug.ModelingMusic;
|
||||
namespace Debug;
|
||||
|
||||
/// <summary>
|
||||
/// 主程序入口 参考 https://blog.csdn.net/oscar999/article/details/141370223
|
||||
/// 在VS Code的终端中,使用dotnet build命令来编译项目。这将在项目目录中生成一个bin文件夹,其中包含编译后的程序集。
|
||||
|
@ -10,6 +8,7 @@ namespace Debug;
|
|||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static void printf(object a)
|
||||
{
|
||||
Console.Write(a);
|
||||
|
@ -23,6 +22,7 @@ public class Program
|
|||
Console.Title = "Tools";//设置窗口标题
|
||||
// 设置控制台输出编码,以支持复杂字符
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
// 切换到英语输入法
|
||||
Console.Clear();
|
||||
Console.CursorVisible = false;
|
||||
new MusicFrom();
|
||||
|
|
Loading…
Reference in New Issue
Block a user