今天看到C#课本上个列子把星号(*)有规则打印在控制台中间位置
程序不难,利用的是光标定位函数Console.SetCursorPosition(x, y)做到的
心想是不是弄出一个动态的图案比较好玩啊,说Gan就Gan~
可是问题来了:
以我毫无艺术细胞且又愚笨无比的大脑,实在想不出什么优美的图案
即使想出来我也未必做的出啊 0.0
最终,还是觉得做出来一个弓箭射出的动态图比较Easy
看到的小伙伴们且喷且珍惜 ...
0x 01 作品展示
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(" *\n * *\n"+ 25 " * *\n * **\n * **\n"+ 26 " * *\n *** * * *\n **********************************\n"+ 27 " *** * * *\n * *\n * **\n"+ 28 " * **\n * *\n * *\n"+ 29 " *\n"); 30 Thread.Sleep(500); 31 Console.Clear(); 32 Console.Write(" *\n * *\n" + 33 " * *\n * **\n * **\n" + 34 " * *\n *** * * *\n " + 35 " *******************************\n *** * * *\n" + 36 " * *\n * **\n * **\n" + 37 " * *\n * *\n *\n"); 38 Thread.Sleep(200); 39 Console.Clear(); 40 Console.Write(" *\n * *\n" + 41 " * *\n * **\n * **\n"+ 42 " * *\n *** * * *\n"+ 43 " ***************************\n *** * * *\n"+ 44 " * *\n * **\n * **\n"+ 45 " * *\n * *\n *\n"); 46 Thread.Sleep(200); 47 Console.Clear(); 48 Console.Write(" *\n * *\n"+ 49 " * *\n * **\n * **\n"+ 50 " * *\n * * *** *\n"+ 51 " * * ***************************\n * * *"+ 52 "** *\n * *\n * **\n"+ 53 " * **\n * *\n"+ 54 " * *\n *\n"); 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+"*** *\n"); 66 Console.SetCursorPosition(0+i, 7); 67 Console.Write(pre+" ***************************\n"); 68 Console.SetCursorPosition(0+i, 8); 69 Console.Write(pre+"*** *\n"); 70 Console.SetCursorPosition(0, 0); 71 Console.Write(" *\n * *\n" + 72 " * *\n * **\n * **\n" + 73 " * *\n * *\n" + 74 " * *\n * *\n * *\n" + 75 " * **\n * **\n * *\n" + 76 " * *\n *\n"); 77 Thread.Sleep(100); 78 Console.Clear(); 79 } 80 81 82 83 Thread.Sleep(500); 84 85 } 86 } 87 } 88 }
基本实现思路在0x 02已经说了,这里就不叙述了~
时间: 2024-10-13 21:53:19