在控制台应用程序中,可以使用ascii转轮,如GUI等待游标,以指示工作正在完成。一个普通的旋转器循环使用以下4个字符:'|','/','-','\'
还有哪些循环动画序列可以为控制台应用程序增添趣味?
在控制台应用程序中,可以使用ascii转轮,如GUI等待游标,以指示工作正在完成。一个普通的旋转器循环使用以下4个字符:'|','/','-','\'
还有哪些循环动画序列可以为控制台应用程序增添趣味?
当前回答
制作一个可爱的“雨”效果:
using System;
using System.Text;
using System.Threading;
namespace CSharpSandbox
{
class Program
{
static Random rnd = new Random();
static char[,] Step(char[,] matrix)
{
int width = matrix.GetUpperBound(0) + 1;
int height = matrix.GetUpperBound(1) + 1;
char[,] res = new char[width, height];
for (int h = 0; h < height; h++)
{
for (int w = 0; w < width; w++)
{
char c;
if (h == 0)
c = rnd.Next(2) == 0 ? ' ' : '*';
else
c = matrix[w, h - 1];
res[w, h] = c;
}
}
return res;
}
static string ToString(char[,] matrix)
{
int width = matrix.GetUpperBound(0) + 1;
int height = matrix.GetUpperBound(1) + 1;
StringBuilder sb = new StringBuilder();
for (int h = 0; h < height; h++)
{
for (int w = 0; w < width; w++)
{
sb.Append(matrix[w, h]);
}
sb.AppendLine();
}
return sb.ToString();
}
static Timer timer;
static void Spinner()
{
char[,] matrix = new char[10, 5];
timer = new Timer(_ =>
{
string s = ToString(matrix);
Console.SetCursorPosition(0, 0);
Console.Write(s);
matrix = Step(matrix);
},
null,
0,
200);
}
static void Main(string[] args)
{
Spinner();
Console.ReadLine();
}
}
}
其他回答
试试这些
“+”,“x” 'v', '<', '^', '>'
我很高兴我不是唯一一个在这上面浪费时间的疯子!
以下是我最喜欢的(一些使用dos ascii码):
classic: "/-\\|";
bouncing ball: ".oOo";
better bouncing ball: [46, 111, 79, 248, 79, 111]; // (.oO°Oo.)
[180, 217, 193, 192, 195, 218, 194, 191]; // ┤ ┘ ┴ └ ├ ┌ ┬ ┐
[185, 188, 202, 200, 204, 201, 203, 187]; // double piped version of that
[219, 220, 223]; // block colours
全部取自:
http://llizard.cwahi.net/animals.html
蝙蝠飞翔!
/^v^\
/^v^\ /^v^\
/^v^\
/^v^\
皮瓣皮瓣!
\^v^/
\^v^/ \^v^/
\^v^/
\^v^/
哇,哇,一个弓箭手!
/\
/__\_{)
|--<<)__\
\ / (
\/ )
/|
\ \
~ ~
/| \
/_|_{)/
---<< | | )
\ | (
\| )
/|
\ \
~ ~
\
/|{)/
---<< +-|-)
\| (
)
/|
\ \
~ ~
/\
/__\_{)
|--<<)__\
\ / (
\/ __)
\ |__
~ ~
/| \
/_|_{)/
---<< | | )
\ | (
\|__)
\ |__
~ ~
\
/|{)/
---<< +-|-)
\| (
__)
\ |__
~ ~
超级自行车
---------- __o
-------- _ \<,_
------- (*)/ (*)
Wheeeee !
放风筝
/\
'\/
' +
' +
' +
' +
' +
' +
'
'
'
'
'
'
'
'
__ '
\o . '
\\/
/\
/ /
这张钓鱼的照片也很搞笑
http://asciimator.net/kangaroo/fishing.html
曾经有一个DOS链接器名为blinker,由Blink Inc.开发。它将在工作时显示类似于下面的动画:
(o)(o)
(-)(-)
(_)(_)
第一帧显示大约一秒钟,其他两帧每一两秒钟简短地显示一次动画,使命令行看起来像是在眨眼。实际上,这个效果非常酷。
链接器甚至可以选择眨一只眼睛,你可以选择眨哪只眼睛。
我用了一个循环
Working.
Working..
Working...
我知道这很鼓舞人心