本文整理汇总了C#中Field.Show方法的典型用法代码示例。如果您正苦于以下问题:C# Field.Show方法的具体用法?C# Field.Show怎么用?C# Field.Show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field.Show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
try
{
// bool game_over = false;
ConsoleKeyInfo cki = new ConsoleKeyInfo();
cki = Console.ReadKey(true);
Field field = new Field(20, 20);
if (Console.KeyAvailable)
{
if (cki.Key == ConsoleKey.LeftArrow)
{
//field.MoveWall();
field.MoveLeft();
// field.Update();
// field.Show();
}
else
if (cki.Key == ConsoleKey.RightArrow)
{
//field.MoveWall();
field.MoveRight();
//field.Update();
//field.Show();
}
}
while (field.MoveWall() > 0)
{
//Console.SetCursorPosition(0, 0);
if (field.MoveWall() > 0)
{
field.MoveWall();
}
else
{
Console.WriteLine("Game over your result: " + (field.ball.score).ToString());
break;
}
//field.MoveWall();
System.Threading.Thread.Sleep(300);
//field.Update();
field.Show();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
示例2: Game
static void Game()
{
try
{
Console.Clear();
is_pause = false;
Field f = new Field(x, y);
f.ball.Lives = lives;
f.ball.GetSym = ball_custom;
f.wall[0].GetSym = wall_custom;
f.wall[1].GetSym = wall_custom;
f.wall[2].GetSym = wall_custom;
// int choise = 0;
bool is_up = false;
Menu menu = new Menu();
Console.WriteLine("Press any key!!!");
ConsoleKeyInfo cki = new ConsoleKeyInfo();
cki = Console.ReadKey(true);
do
{
Console.SetCursorPosition(0, 0);
if (Console.KeyAvailable == true)
{
cki = Console.ReadKey(true);
if (cki.Key == ConsoleKey.LeftArrow)
{
f.ball.MoveLeft();
}
else
if (cki.Key == ConsoleKey.RightArrow)
{
f.ball.MoveRight();
}
else
if (cki.Key == ConsoleKey.M)
{
is_pause = true;
Menu();
}
if (is_exit == true)
{
break;
}
}
// foreach(Wall w in f.wall)
// {
//if (f.ball.X + 1 == w.X && f.ball.Y > w.Y && f.ball.Y < w.Y + w.GetSym().Length)//&& f.ball.Y == w.Y)
if (f.ball.X + 1 == f.wall[0].X && f.ball.Y >= f.wall[0].Y && f.ball.Y <= f.wall[0].Y + f.wall[0].GetSym.Length
|| f.ball.X + 1 == f.wall[1].X && f.ball.Y >= f.wall[1].Y && f.ball.Y <= f.wall[1].Y + f.wall[1].GetSym.Length
|| f.ball.X + 1 == f.wall[2].X && f.ball.Y >= f.wall[2].Y && f.ball.Y <= f.wall[2].Y + f.wall[2].GetSym.Length)
{
is_up = true;
}
else
{
is_up = false;
}
// }
if (is_up == false)
{
f.ball.MoveDown();
}
else
if (is_up == true)
{
f.ball.MoveUp();
}
f.wall[0].MoveWall();
f.wall[1].MoveWall();
f.wall[2].MoveWall();
f.Update();
f.Show();
if (f.ball.lives == 0)
{
//Console.BackgroundColor = ConsoleColor.Red;
Console.Clear();
Console.WriteLine("Game Over \n your score: " + f.ball.score + "\n");
Console.WriteLine("Exit Game?");
menu.Add("1.Yes" , Exit);
menu.Add("2.No" , Menu);
menu.Show();
menu.Run();
}
System.Threading.Thread.Sleep(sllep);
} while (f.ball.lives > 0);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//.........这里部分代码省略.........