一个改编自Flash的游戏。- @echo off&setlocal ENABLEDELAYEDEXPANSION
- title 青蛙跳&color e0&set g=goto start
- :readme
- echo 让左右两边的青蛙互换位置。&echo Y代表黄青蛙,R代表红青蛙。
- echo 输入石头(---)下的数字移动。&echo 青蛙们可以按照上面的方向移一格,
- echo 也可以跳过指定方向的一个青蛙,&echo 落到相邻的空石头上
- echo R重来,E退出&echo.&pause>nul
-
- :ready
- for /l %%i in (1,1,3) do set s%%i=Y
- set s4= &for /l %%i in (5,1,7) do set s%%i=R
- set Y=→&set R=←
-
- :start
- set "qwfx="&set "tpstr="
- for /l %%i in (1 1 7) do (
- if %%i neq 1 set "tpstr= "
- if !s%%i!a==Ya set qwfx=!qwfx!!tpstr! →
- if !s%%i!a==Ra set qwfx=!qwfx!!tpstr! ←
- if "!s%%i!"==" " set qwfx=!qwfx!!tpstr!
- )
- cls&echo now
- echo %qwfx%
- echo, %s1% %s2% %s3% %s4% %s5% %s6% %s7%
- echo --- --- --- --- --- --- ---
- echo 1 2 3 4 5 6 7
- echo.
- set "tpstr=%s1%%s2%%s3%%s4%%s5%%s6%%s7%"
- if "%tpstr:YYRR=%_%tpstr:YRR =%_%tpstr: YYR=%" neq "%tpstr%_%tpstr%_%tpstr%" (
- echo You die^^!
- goto end
- )
- if "%tpstr%"=="RRR YYY" echo You win^^!&&goto end
-
- :input
- set "move="&set /p move=请输入:
- if /i "!move!"=="r" cls&&goto ready
- if /i "!move!"=="e" exit
- set input=&for /l %%e in (1,1,7) do if "%move%"=="%%e" set input=r
- if %input%a neq ra %g%
- if "!s%move%!"==" " %g%
- if !s%move%!==Y (set "movefx=+") else set "movefx=-"
- for %%t in (1 2) do set /a move%%t=%move%%movefx%%%t
- if "!s%move1%!"==" " (set s%move1%=!s%move%!) else (
- if "!s%move2%!"==" " (set s%move2%=!s%move%!) else echo 无法移动。&%g%
- )
- set "s%move%= "&cls&%g%
-
- :end
- set /p restart=再来?(Y,N)
- if /i "%restart%"=="y" goto ready
复制代码
|