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

TOP

2018.10.6前来考古

TOP

本帖最后由 netbenton 于 2021-12-7 00:10 编辑
  1. @echo off&rem 俄罗斯方块游戏,win10测试运行。由netbenton编写,在bathome首发,完成时间:2021年12月06日
  2. if "%1" equ "para2" goto :para2
  3. rem 取控制符到变量。(1BH=27=033)
  4. for /F "tokens=1 delims=#" %%a in ('"prompt #$E# & echo on & for %%b in (1) do rem"') do set "ESC=%%a"
  5. set ebu4=第!guan!关
  6. set ebu6=总分:!fen!
  7. ::各种图标定义
  8. set ga1=0 1 5 6
  9. set ga2=1 4 5 8
  10. ::■■
  11. ::  ■■
  12. set gb1=1 2 4 5
  13. set gb2=0 4 5 9
  14. ::  ■■
  15. ::■■
  16. set za1=4 5 6 7
  17. set za2=1 5 9 d
  18. ::■■■■
  19. set qa1=1 5 9 8
  20. set qa2=0 4 5 6
  21. set qa3=0 1 4 8
  22. set qa4=0 1 2 6
  23. ::■■
  24. ::  ■
  25. ::  ■
  26.   
  27. set qb1=0 4 8 9
  28. set qb2=0 1 2 4
  29. set qb3=0 1 5 9
  30. set qb4=2 4 5 6
  31. ::■■
  32. ::■
  33. ::■
  34. set ta1=0 1 4 5
  35. ::■■
  36. ::■■
  37. set sa1=0 1 2 5
  38. set sa2=1 4 5 9
  39. set sa3=1 4 5 6
  40. set sa4=0 4 5 8
  41. ::  ■
  42. ::■■■
  43. set tw1=0 1
  44. set tw2=0 4
  45. set on1=0
  46. set on2=0
  47. set sh1=1 4 5 6 9
  48. set sh2=1 4 5 6 9
  49. set ao1=0 1 2 4 6
  50. set ao2=0 1 4 8 9
  51. set ao3=0 4 5 6 2
  52. set ao4=0 1 5 8 9
  53. set tt1=0 1 2 5 9
  54. set tt2=0 4 8 5 6
  55. set tt3=1 5 8 9 a
  56. set tt4=2 4 5 6 a
  57. ::cdef
  58. ::89ab
  59. ::4567
  60. ::0123
  61. start "aswd" %0 para2
  62. ::起动控制窗口
  63. set k3=k%%=mx,k+
  64. set k4=down
  65. set k1=m-
  66. set k2=m+
  67. set k5=t+
  68. ::按键定义
  69. setlocal enabledelayedexpansion
  70. for /l %%a in (0,1,10) do (set "ebuf=!ebuf!^!r@.%%a^!")
  71. for %%a in (sa_4 ta_1 qb_4 qa_4 za_2 ga_2 gb_2 tw_2 on_2 sh_2 ao_4 tt_4) do (
  72. for /f "tokens=1,2 delims=_" %%b in ("%%a") do (
  73.   set _%%b=%%c
  74.   for /l %%d in (1,1,%%c) do set/a nx+=1&set ran!nx!=%%b%%d
  75. )
  76. )
  77. ::定义各种图型的可变型数,及单个图的随机号
  78. :restart
  79. cls
  80. echo 0 2 >%~n0.tmp
  81. for /l %%a in (0,1,18) do (for /l %%b in (0,1,10) do set r%%a.%%b= )
  82. set/a fen=0,guan=1
  83. ::初始化坐标空间18行,10列
  84. :loop
  85. set/a "m=4,t=2,n=1,down=450/(guan<<2),bti=0"
  86. set/a r=!random!%%nx+1
  87. set err=
  88. set ttr=!_ttr!
  89. set _ttr=!ran%r%!
  90. ::随机取一个图标,
  91. if not defined ttr goto :loop
  92. set mx=!_%ttr:~,2%!
  93. set k=%ttr:~2%
  94. set str=!%ttr%!
  95. set _str=!%_ttr%!
  96. setlocal enabledelayedexpansion
  97. for %%a in (!_str!) do set/a one=0x%%a,x=one/4+8,y=one%%4&set kk!x!.!y!=■
  98. for /l %%a in (8,1,11) do for /l %%b in (0,1,3) do (
  99. if defined kk%%a.%%b (set kk%%a=!kk%%a!!kk%%a.%%b!) else (set kk%%a=!kk%%a! )
  100. )
  101. endlocal&set ebu8=%kk8%&set ebu9=%kk9%&set ebu10=%kk10%&set ebu11=%kk11%
  102. ::对预备图标的处理
  103. :cont
  104. set/p var=<%~n0.tmp
  105. for /f "tokens=1,2" %%a in ("%var%") do (
  106. if %%a neq !test! (
  107.   if %%b geq 6 call :error %%b&del/q %~n0.tmp&exit
  108.   set bs=!str!&set/a bm=m,bk=k
  109.   set/a !k%%b!=1
  110.   if "%%b" equ "3" (for %%b in ("!ttr:~,2!!k!") do set str=!%%~b!)
  111.   setlocal enabledelayedexpansion
  112. for %%a in (!str!) do (set/a one=0x%%a,x=one/4+n,y=one%%4+m
  113. for %%b in ("r!x!.!y!") do (
  114. if "!%%~b!" equ " " (set r!x!.!y!=■) else (set err=1)
  115. )
  116. )
  117.   rem 调用函数把图标点放置到总坐标空间
  118.   if defined err (
  119.    endlocal
  120.    set/a m=bm,k=bk
  121.    set str=!bs!
  122.   ) else (
  123. echo;%ESC%[0;0H
  124. echo;
  125. echo;
  126. for /l %%a in (2,1,18) do (
  127. for %%b in ("│!ebuf:@=%%a!│  !ebu%%a!") do echo; %%~b
  128. )
  129. echo;
  130.    rem 调用显示函数
  131.    endlocal
  132.   )
  133. )
  134. set test=%%a
  135. )
  136. set ti=1!time:~7,1!!time:~9,2!
  137. if !ti! lss !bti! (set /a tn=ti-bti+1000) else (set /a tn=ti-bti)
  138. if !tn! gtr !down! (
  139. set/a bti=ti,n+=1
  140. setlocal enabledelayedexpansion
  141. for %%a in (!str!) do (set/a one=0x%%a,x=one/4+n,y=one%%4+m
  142. for %%b in ("r!x!.!y!") do (
  143. if "!%%~b!" equ " " (set r!x!.!y!=■) else (set err=1)
  144. ))
  145. if defined err (
  146.   endlocal
  147.   goto :jmpout
  148. ) else (
  149. echo;%ESC%[0;0H
  150. echo;
  151. echo; ┌──────────────────────┐
  152. for /l %%a in (2,1,18) do (
  153. for %%b in ("│!ebuf:@=%%a!│  !ebu%%a!") do echo; %%~b
  154. )
  155. echo; └──────────────────────┘
  156.   endlocal
  157. )
  158. )
  159. goto :cont
  160. :jmpout
  161. set/a n-=1
  162. for %%a in (!str!) do (set/a one=0x%%a,x=one/4+n,y=one%%4+m
  163. for %%b in ("r!x!.!y!") do (
  164. if "!%%~b!" equ " " (set r!x!.!y!=■) else (set err=1)
  165. )
  166. )
  167. set m=18
  168. for /l %%a in (18,-1,2) do for %%b in ("!ebuf:@=%%a!") do if "%%~b" neq "■■■■■■■■■■■" (set e!m!=%%~b&set/a m-=1)
  169. if !m! neq 1 (
  170. for /l %%a in (!m!,-1,2) do set "e%%a=           "
  171. for /l %%a in (18,-1,2) do (
  172.   for /l %%b in (0,1,10) do set r%%a.%%b=!e%%a:~%%b,1!
  173. )
  174. set/a "fen=fen+(m-1)*10,guan=fen/150+1"
  175. )
  176. if !n! leq 2 (
  177. echo 游戏结束!
  178. ping -n 3 127.1 >nul
  179. goto :restart
  180. )
  181. goto :loop
  182. :para2
  183. mode con: cols=30 lines=2
  184. echo a左 d右 w转 s加速 q退出
  185. for %%a in (a d w s g q) do set /a n+=1,K%%a=n
  186. :p_lp
  187. for /F "tokens=2 delims=键" %%L in ('xcopy /w . 2^>nul') do set k=%%L
  188. if not defined K%k% goto :p_lp
  189. set/a n=n%%50+1,k=K%k%
  190. >%~n0.tmp echo;%n% %k%
  191. if %k% geq 6 exit
  192. for /l %%a in (1,1,25) do ver>nul
  193. goto :p_lp
  194. :error
  195. if %1 equ 6 echo 谢谢使用,再见。。。
  196. ping -n 3 127.1 >nul
  197. goto :eof
复制代码
1

评分人数

TOP

回复 33# netbenton 你的代码还是不能在win7下运行啊,显示
[

TOP

回复 34# sds
控制台虚拟终端序列仅支持 Windows 10 / Windows 11
详见:https://learn.microsoft.com/zh-cn/windows/console/console-virtual-terminal-sequences
Why join the navy, if you can be a pirate? - Steve Jobs

TOP

佩服!批处理侦测输入没几个做的这么好的

TOP

返回列表