本文整理汇总了C#中Input.CheckInput方法的典型用法代码示例。如果您正苦于以下问题:C# Input.CheckInput方法的具体用法?C# Input.CheckInput怎么用?C# Input.CheckInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.CheckInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] a)
{
SnakePart snake = new SnakePart();
bool gameOver = false;
bool pause = false;
bool inuse = false;
string newKey = "right"; // 0 = up, 1 = right, 2 = down, 3 = left
string prevKey = newKey;
int boardWidth = Console.WindowWidth; //
int boardHeight = Console.WindowHeight; //
var rng = new Random();
var point = new Point();
var snakeParts = new List<Point>();
Console.CursorVisible = false;
for (int i = 0; i < 4; i++)
{
snakeParts.Add(new Point(10, 10));
}
Console.ForegroundColor = ConsoleColor.Green;
Console.SetCursorPosition(10, 10);
Console.Write("@");
Food food = new Food();
food.DrawFood();
/* while (true)
{
Point.X = rng.Next(0, boardWidth);
Point.Y = rng.Next(0, boardHeight);
bool spot = true;
foreach (Point p in snakeParts)
{
if (p.X == Point.X && p.Y == Point.Y)
{
spot = false;
break;
}
}
if (spot)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.SetCursorPosition(Point.X, Point.Y);
Console.Write("$");
break;
}
}*/
var time = new Stopwatch();
time.Start();
while (!gameOver)
{
/* if (Console.KeyAvailable)
{
ConsoleKeyInfo controls = Console.ReadKey(true); // 0 = up, 1 = right, 2 = down, 3 = left
if (controls.Key == ConsoleKey.Escape)
{
gameOver = true;
}
else if (controls.Key == ConsoleKey.Spacebar)
{
pause = !pause;
}
else if (controls.Key == ConsoleKey.UpArrow && prevKey != "down")
{
newKey = "up";
}
else if (controls.Key == ConsoleKey.RightArrow && prevKey != "left")
{
newKey = "right";
}
else if (controls.Key == ConsoleKey.DownArrow && prevKey != "up")
{
newKey = "down";
}
else if (controls.Key == ConsoleKey.LeftArrow && prevKey != "right")
{
newKey = "left";
}
}*/
if (!pause)
{
if (time.ElapsedMilliseconds < 100)
{
continue;
}
time.Restart();
Input input = new Input();
input.CheckInput();
/* var tail = new Point(snakeParts.First());
var head = new Point(snakeParts.Last());
var newHead = new Point(head);*/
/* switch (newKey)
{
case "up":
newHead.Y -= 1;
//.........这里部分代码省略.........