本帖最后由 netbenton 于 2021-12-27 15:40 编辑
增加了背景虚块!!无可挑剔了。。。- @echo off
- title 批处理俄罗斯方块
- ::win10测试运行。由netbenton编写,bathome首发,更新于:2021年12月24日
- MODE CON: COLS=40 LINES=24
- (FOR /F "TOKENS=1 DELIMS==" %%A IN ('SET') DO SET %%A=
- path %path%
- )
-
- set a=ga1=0 1 5 6;ga2=1 4 5 8;gb1=1 2 4 5;gb2=0 4 5 9;za1=4 5 6 7;za2=1 5 9 d;qa1=1 5 9 8;qa2=0 4 5 6;qa3=2 1 5 9;qa4=4 5 6 a;qb1=1 5 9 a;qb2=2 4 5 6;qb3=0 1 5 9;qb4=4 5 6 8;ta1=5 6 9 a;ta2=5 6 9 a;sa1=1 4 5 6;sa2=1 4 5 9;sa3=4 5 6 9;sa4=1 5 6 9;tw1=5 9;tw2=5 6;on1=9;on2=9;sh1=1 4 5 6 9;sh2=1 4 5 6 9;ao1=0 1 2 4 6;ao2=0 1 4 8 9;ao3=0 4 5 6 2;ao4=0 1 5 8 9;tt1=0 1 2 5 9;tt2=0 4 8 5 6;tt3=1 5 8 9 a;tt4=2 4 5 6 a;k3=k%%=mx,k+;k4=down;k1=y-;k2=y+;k5=暂停;k0=其它键;z=setlocal enabledelayedexpansion;a=!
- set %a:;=&set %
-
- if not exist mk.exe (
- echo;缺少扩展键盘输入的三方【mk.exe】
- pause&goto :eof
- )
-
- for /F "tokens=1 delims=#" %%a in ('"prompt #$E# & echo on & for %%b in (1) do rem"') do set "v=%%a"
- echo;%v%[?25l
-
- for %%a in (1037 1039 13232 1040 11313 12727) do set /a n+=1,k%%a=n
- mk.exe /g
- set/a odt=tt/1000,gmk=0,key1=0,l1=40,l2=120,l3=370,l4=1200,tt=%errorlevel%
-
- %z%
-
- set zmenu=%v%[37m%v%[10;26H 【!a!玩法!a!】%v%[12;26H 第!a!guan!a!关%v%[14;26H 消行:!a!fen!a!%v%[16;26H 【得分】%v%[17;26H !a!fens!a!
-
- call :制表 23 22 zb
-
- set s=a
- for %%a in (b c d e f) do set %%a=!a!!s!!a!&set s=%%a
-
- for /l %%b in (0,1,9) do (
- set gLineText=!gLineText!!b!f!a!d@.%%b!a!!b!
-
- set gLineEcho=!gLineEcho!!c!c!b!d!a!e@!a!.%%b!b!!c!
-
- set pLineTo_0=!pLineTo_0!d@.%%b=0,
-
- )
-
- set pLineTo_0=!pLineTo_0:~,-1!
-
- for /l %%a in (0,1,19) do (
- set e%%a=%%a&set rs=!rs! %%a
- for /f "tokens=*" %%b in ("!pLineTo_0:@=%%a!") do set/a %%b
- set ech=!ech!%v%[B%v%[20D!gLineEcho:@=%%a!
- )
-
- set "rs=!rs! "
-
-
- set n=0
- for /l %%a in (30,1,37) do (
- set c!n!=!v![%%am■
- set f!n!=1
- set /a n+=1
- )
-
-
- for /l %%a in (0,1,3) do (
- set zz=!zz!%v%[B%v%[8D
- for /l %%b in (0,1,3) do (
- set zz=!zz!!b!c!a!k%%a.%%b!a!!b!
- set k%%a.%%b=9
- )
- )
-
- for /l %%a in (0,1,5) do (
- set g#For=!g#For!!c!d!b!e!a!n%%a!a!!b!.!a!m%%a!a!!c!
- set p#To_@=!p#To_@!d!b!e!a!n%%a!a!!b!.!a!m%%a!a!=@,
- set p#To_0=!p#To_0!k!a!n%%a!a!.!a!m%%a!a!=@,
- )
-
- set f0=c9=%v%[2C;zlin=0000000000;简单=sa_4 ta_1 qb_4 qa_4 za_2 ga_2 gb_2;复杂=!a!简单!a! tw_2 on_2 sh_2 ao_4 tt_4;z简单=复杂;z复杂=简单;玩法=简单;f0=0
- set %f0:;=&set %
-
- set c0=%v%[38;2;37;37;37m□
- :rt
-
- %z%
-
- for %%a in (!%玩法%!) do (
- for /f "tokens=1,2 delims=_" %%b in ("%%a") do (
- set _%%b=%%c
- for /l %%d in (1,1,%%c) do (
- set/a nx+=1&set ran!nx!=%%b%%d
- set/a $=0
- set str1=
- for %%e in (!%%b%%d!) do (
- set /a x=0x%%e / 4,y=0x%%e %% 4
- if !x! equ 0 (set x=) else (set x=!x!+)
- if !y! equ 0 (set y=) else (set y=!y!+)
- set str1=!str1!n!$!=!x!x,m!$!=!y!y,
- set /a $+=1
- )
- set %%b%%d=!str1!$=!$!
-
- )
- )
- )
-
- cls
-
- set/a fen=0,guan=1,fens=0
-
- set eev=%ech%
- set eev=%eev%
- set eev=%eev%
-
-
- :l
- set/a "x=-1,t=2,y=3,down=950/(guan*2<<2),bti=0"
- set/a r=!random!%%nx+1,ro=rr,rr=r %% 7+1
-
- set tr=!_tr!
- set _tr=!ran%r%!
- if not defined tr goto :l
-
- set mx=!_%tr:~,2%!
- set k=%tr:~2%
- set str=!%tr%!
- set _str=!%_tr%!
- set aan=
-
- %z%
- set /a x=0,y=0,!_str!,$k=$*13-1
- set p#k=!p#To_0:~,%$k%!
- set /a %p#k:@=rr%
-
- set ekv=%zz%
- for /f "tokens=*" %%a in ("!ekv:9=0!") do (
- endlocal
- set ekv=%%~a
- )
-
- %z%
- set /a x=0,y=0,!str!,$E=$*23,$P=$*20-1,$k=$*13-1
- set p#k=!p#To_0:~,%$k%!
- set /a %p#k:@=ro%
- for /f "tokens=*" %%a in ("%zz%") do (
-
- endlocal
- set eek=%%~a
- set p#=!p#To_@:~,%$P%!
- set g#=!g#For:~,%$E%!
- set z#=!zlin:~,%$%!
- set p#k=!p#To_0:~,%$k%!
-
- )
-
- set p#=!p#:@=%ro%!
-
-
- echo;%v%[4;36H!ekv!%v%[0m%v%[1;1H!zb!%zmenu%
-
-
- :c
- set /a "tt=tt+9, gmk=gmk %% 5+1",kn=0,tin+=1,ti=tt/10-down
-
- if "!gmk!" neq "5" (
- if !ti! gtr !bti! (
-
- set/a bti=tt/10,x+=1,!str!
- FOR /F "TOKENS=*" %%A IN ("%g#%") DO FOR /F "TOKENS=*" %%A IN ("%%A") DO if "!z#!" equ "%%A" (
- set /a x1=x+1,y1=y*2+11
- set /p =%v%[1;23H!eev!%v%[!x1!;!y1!H!eek!%v%[23;4H空格变形,方向控制,回车暂停,Esc退出。<nul
- goto :c
- ) else (
- goto :j
- )
- )
-
- goto :c
-
- )
-
-
-
- if defined 暂停 (call :p&if defined 暂停 endlocal&set 玩法=!z%玩法%!&goto :rt) else (
-
- mk.exe /g /c !tt! >tt.txt
-
- for /f "tokens=1-5" %%1 in (tt.txt) do (
- set /a kn+=1
- set /a key!kn!=k%%1%%2%%3
- )
-
- for /l %%a in (1,1,!kn!) do (
- for /f %%b in ("!key%%a!") do (
-
- if %%b geq 6 goto :exit
- set bs=!str!
- set/a by=y,bk=k,!k%%b!=1
-
- if "%%b" equ "3" for %%b in ("!tr:~,2!!k!") do set str=!%%~b!
-
- set /a !str!
- FOR /F "TOKENS=*" %%A IN ("%g#%") DO FOR /F "TOKENS=*" %%A IN ("%%A") DO if "!z#!" equ "%%A" (
- if "%%b" equ "3" (
- %z%
- set /a x=0,y=0,!str!
-
- set /a %p#k:@=ro%
- for /f "tokens=*" %%a in ("%zz%") do (
- endlocal
- set eek=%%~a
- )
- )
- set /a x1=x+1,y1=y*2+11
- echo;%v%[1;23H!eev!%v%[!x1!;!y1!H!eek!
-
- ) else (
-
- set/a y=by,k=bk
- set str=!bs!
- )
- )
-
- )
-
- )
-
- goto :c
-
- :j
- set /a x1=x,y1=y*2+11,x-=1,$=0
- echo;%v%[1;23H!eev!%v%[!x1!;!y1!H!eek!
-
- set /a !str!
-
- for /f "tokens=*" %%a in ("%p#%") do (set /a %%a)
-
- set/a m=0,n=1
- for %%a in (!rs!) do (
- set /a n+=1
- FOR /F "TOKENS=*" %%A IN ("!gLineText:@=%%a!") DO FOR /F "TOKENS=*" %%A IN ("%%A") DO if "%%A" equ "1111111111" (
- set "rs= %%a!rs: %%a = !"
- set/a m+=1
- set /a "!pLineTo_0:@=%%a!"
- set tx=!tx!!v![!n!;3H■■■■■■■■■■
-
- )
- )
-
-
- if !m! neq 0 (
- set n=0
- for %%a in (!rs!) do (
- set e!n!=%%a
- set /a n+=1,$=n %% 8
- mk /g >nul
- if !$! lss 3 (
- echo;!v![30m!tx!
- ) else (
- echo;!v![3!$!m!tx!
- )
- )
- set tx=
- set/a "fen=fen+m,guan=fen/10+1,fens=fens+l!m!*guan"
- )
-
- set eev=%ech%
- for /l %%a in (1,1,2) do for /f "tokens=*" %%b in ("!eev!") do set eev=%%b
-
- if !x! leq 1 (
- call :记录保存
- endlocal
- goto :rt
- )
-
- goto :l
-
- :记录保存
- echo 游戏结束!
- mk /w /c 3000
- cls
- echo;
- echo;高分排名:
- echo;
- %z%
- for /l %%a in (1,1,5) do set name%%a=无名氏&set zf%%a=0
- set n=0
- for /f "tokens=1,2" %%a in (%~n0.ini) do (
- set /a n+=1
- set name!n!=%%a
- set zf!n!=%%b
- for %%c in (!n!) do echo; %%c !name%%c! !zf%%c!分
- )
- echo;
- echo;
- for /l %%a in (1,1,5) do (
- if not defined find (
- if !fens! gtr !zf%%a! (
- echo;真厉害!本次得分:!fens!分,超过了第%%a名记录保持者:
- echo;【!name%%a!】 !zf%%a! 分
- echo;请留下您的大名:
- set /p name%%a=
- set /a find=zf%%a,zf%%a=fens
- )
- ) else (
- set/a find=zf%%a,zf%%a=!find!
- )
- )
- (
- for /l %%a in (1,1,5) do (
- echo;!name%%a! !zf%%a!
- )
- )>%~n0.ini
-
- endlocal
- goto :eof
-
- :exit
- exit
-
-
- :p
-
-
- set /a dt=tt/1000-odt
- set /a zhen=tin/dt
-
- title 【暂停】!zhen!#!down! 按F2切换玩法,其它键继续。。。
- mk /w /c 999999999 >tt.txt
- for /f "tokens=1-5" %%1 in (tt.txt) do set 暂停=%%1%%2%%3
- if !暂停! neq 10113 set 暂停=
-
- title 批处理俄罗斯方块
- goto :eof
-
-
- :制表 宽 高 变量名
- %z%
-
- set/a 宽2=%1-2,高2=%2-2
- set "%3=!%3!!v!(0l!v!H"
- for /l %%a in (1,1,!宽2!) do (
- set %3=!%3!q
- )
- set %3=!%3!k
- for /l %%b in (1,1,!高2!) do (
- set %3=!%3!%v%[1B%v%[%1Dx%v%[!宽2!Cx
- )
- set %3=!%3!%v%[1B%v%[%1Dm
- for /l %%a in (1,1,!宽2!) do (
- set %3=!%3!q
- )
- set "r=!%3!j!v!(B"
- endlocal&set %3=%r%
- goto :eof
复制代码
|