今天看到C#课本上个列子把星号(*)有规则打印在控制台中间位置
程序不难,利用的是光标定位函数Console.SetCursorPosition(x, y)做到的
心想是不是弄出一个动态的图案比较好玩啊,说Gan就Gan~
可是问题来了:
以我毫无艺术细胞且又愚笨无比的大脑,实在想不出什么优美的图案
即使想出来我也未必做的出啊 0.0
最终,还是觉得做出来一个弓箭射出的动态图比较Easy
看到的小伙伴们且喷且珍惜 ...
0x 01 作品展示
视频我引不过来 = =
先把链接贴上吧
http://v.youku.com/v_show/id_XNzk1NTI4MDQw_type_99.html
0x 02 设计图案素材
我大火影各种炫酷,基情的动画不也是从动漫图一张张拼起来的么
现在先在TXT上把图案先点出来(好费劲我会乱说.......)
Pic 1,2,3,4
素材就用上面四张就 OK了,在C#中让他们延时(sleep)打印出来
最后利用循环和定位函数把箭(➹)射出来
0x 03 代码展示
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading;
6 /*=============================================================================
7 1 * 功能描述:射箭GIF
8 2 * 创 建 者:Anka9080
9 3 * 创建日期:2014/10/2 19:35:05
10 ==============================================================================*/
11 namespace SheJian
12 {
13 class Program
14 {
15 static void Main(string[] args)
16 {
17 Console.Title = "猜猜我射的中不~~~";
18 while (true) {
19 //清屏并设置前景色
20 Console.Clear();
21 Console.ForegroundColor = ConsoleColor.Red;
22 // Console.Beep();
23 // 初始状态
24 Console.Write(" *
* *
"+
25 " * *
* **
* **
"+
26 " * *
*** * * *
**********************************
"+
27 " *** * * *
* *
* **
"+
28 " * **
* *
* *
"+
29 " *
");
30 Thread.Sleep(500);
31 Console.Clear();
32 Console.Write(" *
* *
" +
33 " * *
* **
* **
" +
34 " * *
*** * * *
" +
35 " *******************************
*** * * *
" +
36 " * *
* **
* **
" +
37 " * *
* *
*
");
38 Thread.Sleep(200);
39 Console.Clear();
40 Console.Write(" *
* *
" +
41 " * *
* **
* **
"+
42 " * *
*** * * *
"+
43 " ***************************
*** * * *
"+
44 " * *
* **
* **
"+
45 " * *
* *
*
");
46 Thread.Sleep(200);
47 Console.Clear();
48 Console.Write(" *
* *
"+
49 " * *
* **
* **
"+
50 " * *
* * *** *
"+
51 " * * ***************************
* * *"+
52 "** *
* *
* **
"+
53 " * **
* *
"+
54 " * *
*
");
55 Thread.Sleep(200);
56 Console.Clear();
57
58 for (int i = 1; i < 20; i++)
59 {
60
61 // 定位输出箭头部分代码
62
63 string pre = string.Format("{0,32}",' ');
64 Console.SetCursorPosition(0+i, 6);
65 Console.Write(pre+"*** *
");
66 Console.SetCursorPosition(0+i, 7);
67 Console.Write(pre+" ***************************
");
68 Console.SetCursorPosition(0+i, 8);
69 Console.Write(pre+"*** *
");
70 Console.SetCursorPosition(0, 0);
71 Console.Write(" *
* *
" +
72 " * *
* **
* **
" +
73 " * *
* *
" +
74 " * *
* *
* *
" +
75 " * **
* **
* *
" +
76 " * *
*
");
77 Thread.Sleep(100);
78 Console.Clear();
79 }
80
81
82
83 Thread.Sleep(500);
84
85 }
86 }
87 }
88 }
基本实现思路在0x 02已经说了,这里就不叙述了~