首页 > 编程 > BAT > 正文

炫酷的批处理BAT走字特效源码

2020-07-26 20:13:57
字体:
来源:转载
供稿:网友

先上第一版的代码,
代码肯定还存在BUG,先发上来给大家测试.

@echo off&setlocal enabledelayedexpansionmode con: cols=87 lines=15title code by foxjl 2007-12-1 www.VeVB.COmcolor 1aset long=43,minus=43set,=^我们,是一群执著的批处理爱好者^在色彩斑斓的WINDOWS下,开启CMD这扇深邃的窗口^曾经挑灯夜战,曾经彻夜不眠^我们之所以如此似痴若狂,是因为我们深知:^尺有所短、寸有所长,CMD不同凡响^我们精益求精,力求完美^所有的努力,只为了用最简洁的语言,编写最具实用性的代码^武林网www.VeVB.COm^高手汇聚、资料齐全、是新手入门的福地、老手晋级的乐园^不求最大、但求最好、展现批处理的无穷魅力、一切精彩,尽在~~武林网~~                 演示完毕。再见!!:startecho.for %%i in (8 4 -1 4 -1 4 -1 10 -1 8 -1 16 -7 , 8 4 -1 4 -1 4 -1 10 -1 8 -1 8 -5 4 -1 4 -1 , 8 -4 2 -1 4 -1 10 -4 2 -1 12 -1 2 -7 , 8 4 -1 4 -1 4 -1 2 -1 6 -1 4 -1 2 -2 10 -1 2 -1 4 -1 4 -1 , 8 4 -1 4 -2 2 -2 6 -1 6 -1 2 -1 2 -1 4 -5 4 -1 4 -1 , 8 4 -2 2 -1 4 -1 8 -1 4 -1 4 -1 4 -1 6 -1 2 -7 , 8 -3 4 -1 4 -1 6 -1 2 -1 2 -1 4 -1 12 -1 8 -1 , 8 4 -1 4 -1 4 -1 12 -1 6 -1 12 -1 4 -5 , 8 4 -1 4 -1 2 -2 2 -1 8 -1 6 -1 12 -2 6 -1 , 8 4 -1 4 -2 2 -1 2 -1 6 -1 2 -2 2 -1 8 -2 10 -1 , 8 -3 4 -1 4 -3 2 -2 8 -5 8 -8) do ((if "%%i"=="," (echo.&ping -n 1 127.1>nul)) && (set a=%%i)&(set b=!a:-=!) if %%i lss 0 (for /l %%j in (1,1,!b!) do (set/p=<nul)) else (for /l %%k in (1,1,%%i) do (set/p= <nul) ))call :delay 700echo/&echo/for /l %%z in (1,1,255) do (if not !long! equ 0 set /a long-=1for /l %%j in (1,1,87) do (set/p=<nul)for /l %%k in (1,1,!long!) do (set/p= <nul)set /a longn+=1set /a longs=longn-43set /a remnant=255-43if !longn! lss 43 (set/p=!,:~0,%%z!<nul) else ( if !longn! geq !remnant! (  set /a minus-=1  set /a minuss=minus*2  for /l %%l in (1,1,!minus!) do (set/p= <nul)  for /l %%j in (1,1,!minuss!) do (set/p=<nul)  call set/p=%%,:~!longs!,43%%<nul  ) else (  call set/p=%%,:~!longs!,43%%<nul  ) )call :delay 40 修改这个数字可以调整走字的速度.)call :delay 700&exit:delayfor /l %%i in (1,1,%1) do (error>nul 2>nul)goto :eof

动画效果很不错,象电视里的飞字幕.很有观赏性.

真是开了眼了 set ,=^ 再把每句最后加个^符号,就可以把它们都赋值给变量,?这是什么原理? 并且最后一句末尾又没有^符号?
不过,飞字幕部分,代码似乎可以更简洁.

来看看第二版的代码

:@echo off&setlocal enabledelayedexpansiontitle code by 泛滥慌° 2007-12-1 www.VeVB.COmmode con: cols=87 lines=15for /l %%l in (1 1 42) do set "ko= !ko!"color 1a&echo/&set,=!ko!^我们,是一群执著的批处理爱好者^在色彩斑斓的WINDOWS下,开启CMD这扇深邃的窗口^曾经挑灯夜战,曾经彻夜不眠^我们之所以如此似痴若狂,是因为我们深知:^尺有所短、寸有所长,CMD不同凡响^我们精益求精,力求完美^所有的努力,只为了用最简洁的语言,编写最具实用性的代码^武林网www.VeVB.COm^高手汇聚、资料齐全、是新手入门的福地、老手晋级的乐园^不求最大、但求最好、展现批处理的无穷魅力、一切精彩,尽在~~武林网~~                 演示完毕。再见!!for %%i in (8 4 -1 4 -1 4 -1 10 -1 8 -1 16 -7 , 8 4 -1 4 -1 4 -1 10 -1 8 -1 8 -5 4 -1 4 -1 , 8 -4 2 -1 4 -1 10 -4 2 -1 12 -1 2 -7 , 8 4 -1 4 -1 4 -1 2 -1 6 -1 4 -1 2 -2 10 -1 2 -1 4 -1 4 -1 , 8 4 -1 4 -2 2 -2 6 -1 6 -1 2 -1 2 -1 4 -5 4 -1 4 -1 , 8 4 -2 2 -1 4 -1 8 -1 4 -1 4 -1 4 -1 6 -1 2 -7 , 8 -3 4 -1 4 -1 6 -1 2 -1 2 -1 4 -1 12 -1 8 -1 , 8 4 -1 4 -1 4 -1 12 -1 6 -1 12 -1 4 -5 , 8 4 -1 4 -1 2 -2 2 -1 8 -1 6 -1 12 -2 6 -1 , 8 4 -1 4 -2 2 -1 2 -1 6 -1 2 -2 2 -1 8 -2 10 -1 , 8 -3 4 -1 4 -3 2 -2 8 -5 8 -8) do ((if "%%i"=="," (echo.&ping -n 1 127.1>nul)) && (set a=%%i)&(set b=!a:-=!) if %%i lss 0 (for /l %%j in (1,1,!b!) do (set/p=<nul)) else (for /l %%k in (1,1,%%i) do (set/p= <nul)))call :delay 700&echo/&echo/for /l %%l in (1 1 255) do (  set /p=!,:~0,43!<nul  call :delay 40 修改这个数字可以调整走字的速度.  for /l %%j in (1,1,87) do (set/p=<nul)  set ,=!,:~1!)call :delay 700&exit:delayfor /l %%i in (1,1,%1) do (error>nul 2>nul)goto :eof

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表