找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 2238|回复: 0

【批处理】关灯益智游戏

[复制链接]

12

主题

35

回帖

959

积分

用户组: 大·技术宅

UID
3517
精华
1
威望
36 点
宅币
802 个
贡献
33 次
宅之契约
0 份
在线时间
207 小时
注册时间
2018-3-2
发表于 2019-7-21 18:26:12 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
本帖最后由 套路 于 2019-7-21 18:24 编辑

批处理关灯益智游戏重制版
  1. @echo off
  2. title 关灯
  3. setlocal enabledelayedexpansion
  4. set x=5
  5. set y=4
  6. set c1=█
  7. set c2=□
  8. set c3=□
  9. set c4=□
  10. set n=0
  11. :main
  12. set "v0=          "
  13. for /l %%k in (1,1,%x%) do (
  14. set v0=!v0!  %%k)

  15. for /l %%i in (1,1,%y%) do (
  16. for /l %%o in (1,1,%x%) do (
  17. set a%%o%%i=□))

  18. set /a j=x*y
  19. set /a n1=%random% %% %j%
  20. set /a num=%n1%+2
  21. :rd
  22. if %n%==%num% (
  23. set /a n=0
  24. goto ec
  25. ) else (
  26. set /a n+=1
  27. set /a rx=!random! %% !x!
  28. set /a ry=!random! %% !y!
  29. set /a rx=!rx!+1
  30. set /a ry=!ry!+1
  31. call set a%rx%%ry%=█
  32. goto rd)

  33. :ec
  34. cls
  35. for /l %%t in (1,1,%y%) do (
  36. for /l %%e in (1,1,%x%) do (
  37. if not !a%%e%%t!==□ (goto nx)))
  38. goto win
  39. :nx
  40. echo 关灯游戏规则:将所有█变成□
  41. for /l %%p in (1,1,%y%) do (
  42. set v%%p=     %%p       
  43. for /l %%u in (1,1,%x%) do (
  44. set "v%%p=!v%%p! !a%%u%%p!
  45. ))
  46. for /l %%r in (0,1,%y%) do (
  47. echo !v%%r!)
  48. echo 请输入坐标(都为0进入设置)
  49. set /p gx=列数:
  50. set /p gy=行数:
  51. if %gx%==0 if %gy%==0 (goto st)
  52. set /a gxc=gx+0
  53. set /a gyc=gy+0
  54. if %gx% lss 1 (goto error)
  55. if %gx% gtr %x% (goto error)
  56. if %gy% lss 1 (goto error)
  57. if %gy% gtr %y% (goto error)
  58. if %gx% neq %gxc% (goto error)
  59. if %gy% neq %gyc% (
  60. :error
  61. echo 错误:输入数字错误
  62. pause
  63. cls
  64. goto nx
  65. )
  66. cls
  67. goto cl

  68. :cl
  69. if !a%gx%%gy%!==□ (call set a%gx%%gy%=█) else (call set a%gx%%gy%=□)
  70. set /a cx1=gx+1,cx0=gx-1,cy1=gy+1,cy0=gy-1
  71. if %gx%==1 (
  72. if !a%cx1%%gy%!==□ (call set a%cx1%%gy%=█) else (call set a%cx1%%gy%=□)
  73. )
  74. if %gx%==%x% (
  75. if !a%cx0%%gy%!==□ (call set a%cx0%%gy%=█) else (call set a%cx0%%gy%=□)
  76. )
  77. if %gy%==1 (
  78. if !a%gx%%cy1%!==□ (call set a%gx%%cy1%=█) else (call set a%gx%%cy1%=□)
  79. )
  80. if %gy%==%y% (
  81. if !a%gx%%cy0%!==□ (call set a%gx%%cy0%=█) else (call set a%gx%%cy0%=□)
  82. )

  83. if not %gx%==1 if not %gx%==%x% (
  84. if !a%cx1%%gy%!==□ (call set a%cx1%%gy%=█) else (call set a%cx1%%gy%=□)
  85. if !a%cx0%%gy%!==□ (call set a%cx0%%gy%=█) else (call set a%cx0%%gy%=□)
  86. )
  87. if not %gy%==1 if not %gy%==%y% (
  88. if !a%gx%%cy1%!==□ (call set a%gx%%cy1%=█) else (call set a%gx%%cy1%=□)
  89. if !a%gx%%cy0%!==□ (call set a%gx%%cy0%=█) else (call set a%gx%%cy0%=□)
  90. )
  91. goto ec

  92. :st
  93. cls
  94. echo.
  95. echo.                   游戏难度:
  96. echo.                %c1%.普通[1]
  97. echo.                %c2%.中等[2]
  98. echo.                %c3%.困难[3]
  99. echo.                %c4%.自定义[4]
  100. echo.                ...返回[5]
  101. echo.
  102. set /p gs=请输入数字:
  103. set /a gsc=gs+0
  104. if %gs% lss 1 (goto error2)
  105. if %gs% gtr 5 (goto error2)
  106. if %gs% neq %gsc% (
  107. :error2
  108. echo 错误:输入数字错误
  109. pause
  110. goto st
  111. )
  112. if %gs%==5 (
  113. goto main
  114. )
  115. if %gs%==1 if %c1%==□ (
  116. set c1=█
  117. set c2=□
  118. set c3=□
  119. set c4=□
  120. set x=5
  121. set y=4
  122. goto st
  123. )
  124. if %gs%==2 if %c2%==□ (
  125. set c2=█
  126. set c1=□
  127. set c3=□
  128. set c4=□
  129. set x=7
  130. set y=6
  131. goto st
  132. )
  133. if %gs%==3 if %c3%==□ (
  134. set c3=█
  135. set c1=□
  136. set c2=□
  137. set c4=□
  138. set x=10
  139. set y=10
  140. goto st
  141. )
  142. if %gs%==4 (
  143. set c4=█
  144. set c1=□
  145. set c2=□
  146. set c3=□
  147. echo 请输入自定义行列数
  148. set /p x=列数:
  149. set /p y=行数:
  150. set /a xc=!x!+0
  151. set /a yc=!y!+0
  152. if !x! lss 3 (goto error3)
  153. if !y! lss 3 (goto error3)
  154. if !x! neq !xc! (goto error3)
  155. if !y! neq !yc! (
  156. :error3
  157. echo 错误:输入数字错误[注:最小不能小于3]
  158. pause
  159. set x=5
  160. set y=4
  161. cls
  162. goto st
  163. )
  164. goto st
  165. )
  166. goto st

  167. :win
  168. echo.
  169. echo.
  170. echo.
  171. echo                 你赢了
  172. pause
  173. goto main
复制代码

2019-07-21-2.png
...自定义列数大于10坐标数就对不准...不过也不会也没有人设置怎么高折磨自己吧。
游戏规则:点击一个方块,自身和附近方块会变成另一种颜色,当所有方块都为□时游戏胜利。
例如点击下方中间方块,如图变化。
□ □ □        □ █ □
□ █ □  --→  █ □ █
□ □ □        □ █ □
可惜bat没有自定义GUI,不然可以实现点击方块更加还原了(其实时懒得换一个语言)
游戏搬运于mc服务器hypixel的某个角落:
2019-07-21-1.png
回复

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-20 03:01 , Processed in 0.039079 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表