批处理实现乱雨纷飞(黑客帝国特效)
废话少说,直接先上一个特效代码
@echo off&mode con cols=42 lines=20&color 02 set m=1&set v=1 set code==^^^&%%%^:!$#^>^<:=~*()@"'`;\|-_+?,.ghijklmnopqrstuvwxyz0123456789abcdef setlocal enabledelayedexpansion :begin set /a num=%random%%%40+1,num1=num,num=200/num title 乱雨纷飞,当前雨量:%num1% :lp set /a a=%random%%%63,b=%random%%%%num% set a=!code:~%a%,1! if %b% equ 0 (set "b=!a!") else (set "b= ") set str%m%=!str%m%!!b! set /a n+=1 if %n% lss 40 goto lp set /a x+=1,w+=1 if %x% equ 40 call :lop cls&for /l %%i in (%m%,-1,%v%) do echo.!str%%i! set /a m+=1 if %m% geq 20 set /a v+=1 if %w% equ 100 (set w=0&goto begin) else (set n=0&goto lp) :lop set /a a=%random%%%15+1 set a=!code:~-%a%,1! color 0!a!&set x=0
有小伙伴说了,为什么不把它改成下落 101010 的呢?那样的话不是像黑客帝国里的画面了码???
好吧,我们来把他实现
@echo off&mode con cols=42 lines=20&color 02 setlocal enabledelayedexpansion set code=123456789abcdef set m=1&set v=1 title 黑客帝国数码雨 by bat-zw19750516 :begin set /a a=%random%%%2,b=%random%%%3 if %b% neq 0 (set b=%a%) else (set "b= ") set str=%str%%b% set /a n+=1 if %n% lss 40 goto begin set /a m+=1,x+=1 if %m% geq 20 set /a v+=1 set str%m%=%str% cls&for /l %%i in (%m%,-1,%v%) do echo.!str%%i! if %x% equ 20 call :lp set str=&set n=0 goto begin :lp set /a a=%random%%%15,x=0 set a=!code:~%a%,1! color 0%a%
当然上面的是高手写的,我们来看个新手简单完成的样子
@echo off title 黑客帝国数码雨效果 color 02 setlocal ENABLEDELAYEDEXPANSION for /l %%i in (1,1,80) do ( set Down%%i=0 ) :heike for /l %%j in (1,1,80) do ( set /a guxing%%j-=1 if !guxing%%j! LSS 0 ( set /a hanye%%j=!random!%%4 set /a guxing%%j=!random!%%15+10 ) if "!hanye%%j!" == "1" ( set /a shu=!random!%%2 set /p=!shu!<NUL ) else ( set /p= <NUL ) ) goto heike
是不是对这种特效有了新的认识了呢,是不是立刻就想精通批处理了呢,努力吧,小伙子们。
赞 (0)