[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[特效代码] 用bat写一个数码雨脚本

相信大家都看过黑客帝国,也都知道宣传海报中的数码雨
菩提本无树,明镜亦非台。
本是无一物,何处惹尘埃。

回复 1# 牛虻
  1. title 黑客帝国数码雨
  2. @echo %dbg% off
  3. :: Code by redtek 2006-11-2 CMD@XP
  4. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  5. setlocal ENABLEDELAYEDEXPANSION
  6. mode con cols=80 lines=30
  7. cls
  8. set 退格=
  9. set redtek=" "
  10. set end=0
  11. :start
  12. set /a end+=1
  13. call :calc
  14. set /p=!setspaces! nul
  15. set /p=%退格%<NUL
  16. set /p=%redtek:~1,79%<NUL&ECHO.
  17. goto :start
  18. :calc
  19. if %end%==28 (
  20. set /a end=0 & cls & set /a cols=!random:~0,2!
  21. echo ... 风力:!cols! ...
  22. if !cols! GTR 76 set cols=76
  23. if !cols! LSS 2 set cols=2
  24. set setspaces=!redtek:~1,%cols%!!random:~0,1!
  25. goto :eof
  26. )
  27. @echo off
  28. :: Code by JM 2006-11-3 CMD@XP
  29. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  30. :: test.txt内容为:1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#%&*(){}[]_+-=\"'?.,/
  31. :: 暂时不能处理 |<>^
  32. mode con cols=80
  33. color 02
  34. for /f %%i in (test.txt) do set str_char=%%i
  35. set str_blank=
  36. setlocal enabledelayedexpansion
  37. :loop
  38. :: 取随机位置上的字符
  39. set /a num_char=1%random:~-1%%random:~0,1%-100
  40. set char=!str_char:~-%num_char%,1!
  41. :: 设置随机长度的空格
  42. set /a num_blank=1%random:~-1%%random:~0,1%-100
  43. set blank=!str_blank:~0,%num_blank%!
  44. echo.%blank%%char%
  45. goto loop
  46. @echo off
  47. :: Code by 不得不爱 2006-11-3 CMD@XP
  48. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  49. mode con cols=80
  50. set a=1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#%.*(){}[]_+-=\"'?.,/^&^^^>^<
  51. set b=
  52. setlocal enabledelayedexpansion
  53. :a
  54. set /a num=%random%%%92
  55. set 字符=!a:~-%num%,1!
  56. set/a c=%random%%%80
  57. set 空格=!b:~-%c%!
  58. echo %空格%^%字符%
  59. goto a
  60. @echo off
  61. :: Code by yfd11 2006-11-3 CMD@XP
  62. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  63. mode con cols=80 LINES=30
  64. set a=1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#%.*(){}[]_+-=\"'?.,/^&^^^>^<
  65. set b=
  66. setlocal enabledelayedexpansion
  67. :a
  68. set /a num=%random%%%92
  69. set 字符=!a:~-%num%,1!
  70. set/a c=%random%%%80
  71. set 空格=!b:~-%c%!
  72. ::echo. %空格%^%字符%
  73. set/a i+=1
  74. rem 指针=i 尾指针=j
  75. set/a j=i-30
  76. set line%i%=%空格%^%字符%
  77. FOR /L %%v IN (%i%,-1,%j%) DO echo.!line%%v!
  78. ::ping /n 127.1>nul
  79. goto a
  80. @echo off
  81. :: Code by hxuan999 2006-11-12 CMD@XP
  82. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  83. ::mode con cols=80
  84. setlocal ENABLEDELAYEDEXPANSION
  85. color 02
  86. goto BEGIN
  87. goto :eof
  88. ::function mt_rand "a" "b"
  89. :mt_rand
  90. ::(
  91. set a=%~1
  92. set b=%~2
  93. set /a _mt_rand=(!random!%%(%b%-%a%))+%a%
  94. exit /b 0
  95. ::)
  96. :BEGIN
  97. ::{--
  98. SET iWidth=80
  99. SET iDensity=6
  100. SET sText="#$&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
  101. SET sText=!sText:"=!
  102. set /A iText=90-1
  103. for /l %%i in (1,1,%iWidth%) do (
  104. set aDown%%i=0
  105. )
  106. :loop
  107. for /l %%I in (1,1,%iWidth%) do (
  108. set /a aDown%%I-=1
  109. if !aDown%%I! LSS 0 (
  110. call :mt_rand "0" "%iDensity%"&&set aArrow%%I=!_mt_rand!
  111. call :mt_rand "10" "25"&&set aDown%%I=!_mt_rand!
  112. )
  113. if !aArrow%%I! EQU 1 (
  114. call :mt_rand "0" "%iText%"&&(FOR %%M IN ("!_mt_rand!") DO SET aa=!sText:~%%~M,1!)
  115. set /p=!aa!<NUL
  116. ) else (
  117. set /p= <NUL
  118. )
  119. )
  120. goto loop
  121. ::--}
  122. :exit
  123. exit /b 0
  124. @echo off
  125. :: Code by hxuan999 2006-11-12 CMD@XP
  126. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  127. setlocal ENABLEDELAYEDEXPANSION
  128. color 02
  129. for /l %%i in (1,1,80) do (
  130. set Down%%i=0
  131. )
  132. :loop
  133. for /l %%j in (1,1,80) do (
  134. set /a Down%%j-=1
  135. if !down%%j! LSS 0 (
  136. set /a Arrow%%j=!random!%%4
  137. set /a Down%%j=!random!%%15+10
  138. )
  139. if "!Arrow%%j!" == "1" (
  140. set /a chr=!random!%%2
  141. set /p=!chr!<NUL
  142. ) else (
  143. set /p= <NUL
  144. )
  145. )
  146. goto loop
  147. goto :eof
  148. @echo off
  149. :: Code by newaifi 2006-11-16 CMD@XP
  150. :: 出处:http://www.cn-dos.net/forum/viewthread.php?tid=24418
  151. setlocal ENABLEDELAYEDEXPANSION
  152. for /l %%i in (1,1,80) do (
  153. set Down%%i=0
  154. )
  155. for /l %%i in (0) do (
  156. set line=
  157. for /l %%j in (1,1,80) do (
  158. set /a Down%%j-=1
  159. call set x=!down%%j!
  160. if !x! LSS 0 (
  161. set /a Arrow%%j=!random!%%6
  162. set /a Down%%j=!random!%%15+10
  163. )
  164. call set x=!Arrow%%j!
  165. if "!x!" == "1" (
  166. set line=!line!1
  167. ) else (set "line=!line! ")
  168. )
  169. call set /p=!line!<NUL
  170. )
复制代码
运行完不对
菩提本无树,明镜亦非台。
本是无一物,何处惹尘埃。

TOP

  1. @echo off & title The Matrix & setlocal enabledelayedexpansion
  2. for /f "tokens=2 delims=[]" %%a in ('ver') do for /f "tokens=2 delims=. " %%a in ("%%a") do set /a "FullScreen=-((%%a-6)>>31)"
  3. if "%1"=="" (
  4.   for %%a in (  FontSize:00060004
  5.                 FontFamily:00000030
  6.                 WindowSize:00320050
  7.                 ScreenColors:0000000a
  8.                 CodePage:000001b5
  9.                 ScreenBufferSize:00320050
  10.                 FullScreen:!FullScreen!
  11.   ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
  12.     >nul reg add HKCU\Console\TheMatrix /v %%b /t reg_dword /d 0x%%c /f
  13.   )
  14.   start "TheMatrix" /max "%ComSpec%" /c "%~s0" 1 & exit
  15. ) else ( >nul reg delete HKCU\Console\TheMatrix /f )
  16. REM "Main Title/Trinity Infinity" – 3:54
  17. if exist "%~dp0matrix4.mp3" (
  18.     start /min wmplayer "%~dp0matrix4.mp3"
  19. ) else (
  20.     start /min wmplayer http://pisa.ucsd.edu/cse125/2001/cse190g1/matrix4.mp3
  21. )
  22. set "Matrix="
  23. set /a "wid=80,hei=50,iMax=wid*hei, sumOfStream=wid*1/2"
  24. for /l %%i in (1 1 !iMax!) do set "Matrix= !Matrix!"
  25. set "bss=!Matrix: =!"
  26. set "dic=*_-+|<>'`:.1麴9痫?ō83佧?70?6??
  27. set "dicLen=42"
  28. for /l %%# in (1 1 !sumOfStream!) do set "s%%#=0"
  29. for /l %%* in (0 0 0) do (
  30.   for /l %%# in (1 1 !sumOfStream!) do (
  31.     if !s%%#! leq 1 (
  32.       set /a "h%%#=!random!%%(hei-1)+2,p0%%#=!random!%%(wid*(hei+1-h%%#))+1,l%%#=!random! %% h%%# + 1,s%%#=l%%#+h%%#,h%%#+=1,pg%%#=p0%%#,pc%%#=p0%%#"
  33.     )
  34.     set /a "s%%#-=1,l%%#-=1,h%%#-=1,old=(l%%#-1)>>31,grow=-h%%#>>31, old0=-^!l%%#,pc%%#=(old0&p0%%#)|(~old0&pc%%#)"
  35.     if !old! neq 0 (set "chrc= ") else set "chrc="
  36.     if !grow! neq 0 (
  37.       set /a "r=!random! %% dicLen"
  38.       for %%r in (!r!) do set "chrg=!dic:~%%r,1!"
  39.     ) else set "chrg="
  40.     for %%i in (g c) do (
  41.       if defined chr%%i (
  42.         set /a "lL=p%%i%%#-1, lR=iMax-p%%i%%#, r=!random! %% dicLen"
  43.         for /f "tokens=1-3" %%a in ("!lL! !p%%i%%#! !lR!") do (set "Matrix=!Matrix:~0,%%a!!chr%%i!!Matrix:~%%b,%%c!")
  44.         set /a "p%%i%%#+=wid"
  45.       )
  46.     )
  47.   )
  48.   cls & <nul set /p "=!Matrix:~0,-1!"
  49. )
  50. exit
复制代码

TOP

本帖最后由 523066680 于 2014-9-12 16:02 编辑

回复 2# 牛虻

      好像CN-DOS以前有个帖子的数码雨效果和这个类似?
不断在尾行增加使得数字“雨”不断往上推。这种方法的话,代码可以更简短的恩。
更好的效果参考3楼

TOP

怎么还用到了 wmplayer 了  ::start /min wmplayer
窗口大小能改变吗?
菩提本无树,明镜亦非台。
本是无一物,何处惹尘埃。

TOP

返回列表