diff --git a/MinLong/Main.cs b/MinLong/Main.cs index 479f72c..b169406 100644 --- a/MinLong/Main.cs +++ b/MinLong/Main.cs @@ -19,7 +19,7 @@ public class Main // 设置计时器事件处理方法 timer.Elapsed += (sender, e) => { - new Thread(() => Zhangaiwu.newshitou(xiaoLong)).Start(); + new Thread(() => Zhangaiwu.Newshitou(xiaoLong)).Start(); int interval = random.Next(3000, 6000); // 1000ms 到 5000ms timer.Interval = interval; }; @@ -100,6 +100,7 @@ public class Main public int x;//小龙X坐标 public int y;//小龙Y坐标 public bool istiao = false;//是否跳 + public bool islong = false;//是否长按跳 //分数 public int score = 0; @@ -142,7 +143,8 @@ public class Main { //空格 case ConsoleKey.Spacebar: - if (!xiaoLong.istiao) { new Thread(() => tiaoyue(xiaoLong)).Start(); } + if (!xiaoLong.istiao) { new Thread(() => tiaoyue(xiaoLong)).Start(); break; } + xiaoLong.islong = true; break; } } @@ -168,11 +170,16 @@ public class Main } for (int i = 0; i < 3; i++) { + if (xiaoLong.islong) + { + Thread.Sleep(50); + } Program.chars[xiaoLong.y, xiaoLong.x].Char = Program.ShowChar; xiaoLong.y += 1; Program.chars[xiaoLong.y, xiaoLong.x].Char = xiaoLong.Char; Thread.Sleep(100); } + xiaoLong.islong = false; xiaoLong.istiao = false; } diff --git a/MinLong/Zhangaiwu.cs b/MinLong/Zhangaiwu.cs index 550c952..cb7e8be 100644 --- a/MinLong/Zhangaiwu.cs +++ b/MinLong/Zhangaiwu.cs @@ -1,10 +1,13 @@ + + +using System.Diagnostics; namespace Debug.MinLong; #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 public class Zhangaiwu { private static int SleepTime = 100; - public static void newshitou(Main.XiaoLong xiaoLong) + public static void Newshitou(Main.XiaoLong xiaoLong) { var y = Program.chars.GetLength(0); var x = Program.chars.GetLength(1); @@ -14,16 +17,14 @@ public class Zhangaiwu y = y - 1 }; bool isjiafeng = false;//是否加分 - bool ceshi = false; for (int i = 1; i < x; i++) { - //测试 - if (!ceshi && shitou.x == xiaoLong.x + 1) - { - ceshi = true; - new Thread(() => Main.tiaoyue(xiaoLong)).Start(); - // Main.tiaoyue(xiaoLong); - } + // System.Diagnostics.Debug.WriteLine("shitou"); + // //测试 自动跳跃 + // if (!xiaoLong.istiao && shitou.x == xiaoLong.x + Program.random.Next(1, 2)) + // { + // new Thread(() => Main.tiaoyue(xiaoLong)).Start(); + // } if (shitou.x != xiaoLong.x || shitou.y != xiaoLong.y) { Program.chars[shitou.y, shitou.x].Char = '0'; @@ -31,7 +32,7 @@ public class Zhangaiwu { isjiafeng = true; xiaoLong.score++; - SleepTime--; + if (SleepTime > 20) SleepTime--; } } else @@ -39,6 +40,10 @@ public class Zhangaiwu Program.IsWhile = false; } Thread.Sleep(SleepTime); + if (shitou.x == xiaoLong.x && shitou.y == xiaoLong.y) + { + Program.IsWhile = false; + } Program.chars[shitou.y, shitou.x].Char = Program.ShowChar; --shitou.x; } diff --git a/ModeSwitch.cs b/ModeSwitch.cs index d8504da..e8663d8 100644 --- a/ModeSwitch.cs +++ b/ModeSwitch.cs @@ -38,8 +38,10 @@ public class ModeSwitch switch (key.Key) { case ConsoleKey.UpArrow: + case ConsoleKey.W: mode--; break; + case ConsoleKey.S: case ConsoleKey.DownArrow: mode++; break; diff --git a/Program.cs b/Program.cs index 5da6f61..5be56fe 100644 --- a/Program.cs +++ b/Program.cs @@ -46,6 +46,7 @@ public class Program public static bool IsWhile = true; public const char ShowChar = ' '; + public static Random random = new(); public Program() {