By HOPE2021复制代码
- @echo off
- chcp 936 > nul
- title 迷宫
- Mode Con: Cols=30 Lines=15
- color 0f
- set Level=0
- set x=1
- set y=1
- @goto Level
- :Start
- if %win%==1 goto End
- Mode Con: Cols=30 Lines=15
- set s=%key%
- call :Area 1 9 1 9
- for /l %%i in (1,1,9) do (
- for /l %%j in (1,1,9) do (
- set "s%%i%%j= "
- )
- )
- set s99=门
- if %Level% leq 2 (
- call :%Level%
- )
- if %Level% geq 3 (
- set Key=0
- call :Rand
- )
- set s%x%%y%=♀
- Mode Con: Cols=30 Lines=15
- call :Visual
- call :get_key
- set s=%key%
- for %%i in (w a s d) do (
- if /i "%s%"=="%%i" (
- set msg=上一步:%s%
- call :%%i
- )
- )
- call :win
- if "%valid_key%" equ "0" goto Start
- :w
- set /a x=%x%-1
- goto :eof
- :a
- set /a y=%y%-1
- goto :eof
- :s
- set /a x=%x%+1
- goto :eof
- :d
- set /a y=%y%+1
- goto :eof
- :Obstacle
- if /i "s%x%%y%"=="s%1" (
- if /i "%s%"=="w" (
- set /a x+=1
- )
- if /i "%s%"=="a" (
- set /a y+=1
- )
- if /i "%s%"=="s" (
- set /a x-=1
- )
- if /i "%s%"=="d" (
- set /a y-=1
- )
- goto :eof
- )
- goto :eof
- :Visual
- cls
- title 迷宫 No.%Level% 〖%title%〗
- echo.
- echo. No.%Level% 〖%title%〗
- echo. ■■■■■■■■■■■
- echo. ■%s11%%s12%%s13%%s14%%s15%%s16%%s17%%s18%%s19%■
- echo. ■%s21%%s22%%s23%%s24%%s25%%s26%%s27%%s28%%s29%■
- echo. ■%s31%%s32%%s33%%s34%%s35%%s36%%s37%%s38%%s39%■
- echo. ■%s41%%s42%%s43%%s44%%s45%%s46%%s47%%s48%%s49%■
- echo. ■%s51%%s52%%s53%%s54%%s55%%s56%%s57%%s58%%s59%■
- echo. ■%s61%%s62%%s63%%s64%%s65%%s66%%s67%%s68%%s69%■
- echo. ■%s71%%s72%%s73%%s74%%s75%%s76%%s77%%s78%%s79%■
- echo. ■%s81%%s82%%s83%%s84%%s85%%s86%%s87%%s88%%s89%■
- echo. ■%s91%%s92%%s93%%s94%%s95%%s96%%s97%%s98%%s99%■
- echo. ■■■■■■■■■■■
- echo. X: %x%,Y: %y% %msg%
- goto :eof
- :get_key
- set "key="
- for /f "delims=" %%a in ('xcopy /w "%~f0" "%~f0" 2^>nul') do if not defined key set "key=%%a"
- set "key=%key:~-1%"
- set "valid_key=0"
- cls
- goto :eof
- :Area
- if /i %x% lss 1 set x=%1
- if /i %x% gtr 9 set x=%2
- if /i %y% lss 1 set y=%3
- if /i %y% gtr 9 set y=%4
- goto :eof
- :Level
- color 0f
- set "msg="
- set /a Level+=1
- set x=1
- set y=1
- set Win=0
- goto Start
- :End
- cls
- color 4e
- for /l %%i in (1,1,9) do (
- for /l %%j in (1,1,9) do (
- set "s%%i%%j= "
- )
- )
- for %%i in (%Map%) do (
- set s%%i=□
- )
- set s99=♀
- Mode Con: Cols=30 Lines=17
- call :visual
- echo. ^>^> 你赢了!!!
- echo. ^>^> 按回车键开始下一关...
- pause > nul
- goto :Level
- :End_If
- if /i "s%x%%y%"=="%1" (
- set Win=1
- ) else (
- set Win=0
- )
- goto :eof
- :2
- set Map=13 17 22 23 25 27 35 37 41 42 43 44 45 47 57 62 63 64 65 66 67 74 78 82 84 86 88 92 96
- set title=层叠石障
- call :Map
- call :win
- goto :eof
- :1
- set Map=13 56 67 23 56 77 34 65 65 34 45 78 27 89 29 37 87 14 28
- set title=小试身手
- call :Map
- call :win
- goto :eof
- :Rand
- set /a Key=%Random%%%8+1
- call :%Key%
- set title=随机迷阵
- call :Obstacle %Map%
- goto :eof
- :3
- set Map=21 22 23 24 35 26 27 28 38 48 58 68 78 88 98 87 32 54 67 83 74 46 34 38 63 53
- call :Map
- call :win
- goto :eof
- :4
- set Map=11 22 33 44 55 66 77 88
- call :Map
- call :win
- goto :eof
- :5
- set Map=19 28 37 46 55 64 73 82 91
- call :Map
- call :win
- goto :eof
- :6
- set Map=19 28 37 46 55 64 73 82 91 11 22 33 44 55 66 77 88
- call :Map
- call :win
- goto :eof
- :7
- set Map=11 12 13 14 15 16 17 18 19 21 31 41 51 61 71 81 91 89 88 98 69 68 67 66 76 86 96 49 48 47 46 45 44 54 64 74 84 94
- call :Map
- call :win
- goto :eof
- :8
- set Map=12 21 22 14 24 34 44 41 42 43 16 26 36 46 56 66 61 62 63 64 65 19 29 39 49 59 69 79 89 91 92 93 94 95 96 97 98
- call :Map
- call :win
- goto :eof
- :win
- if /i "%x%%y%"=="99" (
- set win=1
- )
- goto :eof
- :Map
- for %%i in (%Map%) do (
- set s%%i=□
- call :Obstacle %%i
- )
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |