优化小龙游戏动画
This commit is contained in:
parent
a077d2082e
commit
24d6917c69
|
@ -40,6 +40,7 @@ public class Main
|
||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
double totalTime = 0;
|
double totalTime = 0;
|
||||||
int i; int j;
|
int i; int j;
|
||||||
|
int p = 0;
|
||||||
var a = Program.chars.GetLength(0);
|
var a = Program.chars.GetLength(0);
|
||||||
var b = Program.chars.GetLength(1);
|
var b = Program.chars.GetLength(1);
|
||||||
var buffer = new StringBuilder();
|
var buffer = new StringBuilder();
|
||||||
|
@ -49,6 +50,10 @@ public class Main
|
||||||
Console.SetCursorPosition(0, 0);// 设定光标位置
|
Console.SetCursorPosition(0, 0);// 设定光标位置
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
|
|
||||||
|
|
||||||
|
xiaoLong.Char = xiaoLong.Char == '웃' ? '유' : '웃';
|
||||||
|
Program.chars[xiaoLong.y, xiaoLong.x].Char = xiaoLong.Char;
|
||||||
for (i = 0; i < a; i++)
|
for (i = 0; i < a; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < b; j++)
|
for (j = 0; j < b; j++)
|
||||||
|
@ -69,7 +74,16 @@ public class Main
|
||||||
|
|
||||||
for (i = 0; i < b; i++)
|
for (i = 0; i < b; i++)
|
||||||
{
|
{
|
||||||
buffer.Append('-');
|
p = p == i % 2 ? 1 : 0;
|
||||||
|
if (p == 0)
|
||||||
|
{
|
||||||
|
buffer.Append(' ');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
buffer.Append('-');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Console.Write(buffer);
|
Console.Write(buffer);
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
@ -95,7 +109,7 @@ public class Main
|
||||||
|
|
||||||
public class XiaoLong
|
public class XiaoLong
|
||||||
{
|
{
|
||||||
public char Char = 'k';//小龙的形状
|
public char Char = '웃';//小龙的形状
|
||||||
public ConsoleColor Color = ConsoleColor.Red;//小龙的颜色
|
public ConsoleColor Color = ConsoleColor.Red;//小龙的颜色
|
||||||
public int x;//小龙X坐标
|
public int x;//小龙X坐标
|
||||||
public int y;//小龙Y坐标
|
public int y;//小龙Y坐标
|
||||||
|
@ -143,6 +157,7 @@ public class Main
|
||||||
{
|
{
|
||||||
//空格
|
//空格
|
||||||
case ConsoleKey.Spacebar:
|
case ConsoleKey.Spacebar:
|
||||||
|
case ConsoleKey.PageUp:
|
||||||
if (!xiaoLong.istiao) { new Thread(() => tiaoyue(xiaoLong)).Start(); break; }
|
if (!xiaoLong.istiao) { new Thread(() => tiaoyue(xiaoLong)).Start(); break; }
|
||||||
xiaoLong.islong = true;
|
xiaoLong.islong = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user