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