支持 exist,你真是厉害。
下载:贪吃蛇
[ Last edited by wxcute on 2008-10-10 at 21:08 ]
下载:贪吃蛇
@echo off
if "%1"=="kzck" goto kzck
start "" %0 kzck
title 贪吃蛇 - made by 523066680
mode con cols=65 lines=33
color 31
:newGame
set/a fasttime=3,level=0
:bg
cls
%endset%
set fen=0&set space=
set/a fasttime-=1,level+=1,endlong=50
::endlong为一关结束时的蛇长度,可自己修改
::不过第三关会快得惊人,哈哈哈
setlocal
set endset=endlocal
setlocal enabledelayedexpansion
for /l %%a in (1,1,30) do set space= !space!
for /l %%a in (1,1,30) do set L%%a=%space%
set/a line=15,col=15,i=0,long=3
if %fasttime% lss 0 goto :missionAllOver
echo 移走小窗口。&echo.&echo.&echo.&echo.&echo. 第 %level% 关
echo.&echo.&echo.&echo.&echo.&echo 移走小窗口。
ping -n 4 127.1 >nul
:loop
set wayOld=%way%
call :setWay
if %way%==q goto :gameAllOver
if %way%==r goto :playAgain
for %%p in (ws sw ad da) do if %wayOld%%way%==%%p set way=%wayOld%
if %way%==w set/a linenext=line-1,colnext=col
if %way%==s set/a linenext=line+1,colnext=col
if %way%==a set/a linenext=line,colnext=col-1
if %way%==d set/a linenext=line,colnext=col+1
for %%a in (line col) do (
if !%%a! lss !%%anext! (set %%aadd=+) else set %%aadd=-
)
if not defined dot call :dot
if %i% lss %long% (set/a i+=1) else set i=1
if defined %line%_%col% goto gameover
if defined cut%i% (
!cut%i%:"=!
set "L%a%=!L%a%:~0,%b%! !L%a%:~%c%!"
set "%a%_%b%="
)
if %line% equ 31 goto gameover
if %line% equ 0 goto gameover
if %col% equ -1 goto gameover
if %col% equ 30 goto gameover
set/a C2=col+1
set "L%line%=!L%line%:~0,%col%!□!L%line%:~%C2%!"
set cut%i%="set/a a=%line%,b=%col%,c=%C2%"
set "%line%_%col%=exist"
if "%line%_%col%"=="%dotl%_%dotc%" (set/a long+=1,fen+=100 &set dot=)
cls
echo, %space: =__%__
for /l %%a in (1,1,30) do echo,│!L%%a!│
set fen=%fen%----
set fen=%fen:~,5%
echo, ------------------第%level%关-----------分数:%fen%------------------
if %long% geq %endlong% call :finishlevel&goto :bg
set fen=%fen:-=%
for /l %%t in (1 1 %fasttime%) do ping -n 1 127.1 >nul
if %line% neq %linenext% set/a line%lineadd%=1
if %col% neq %colnext% set/a col%coladd%=1
goto loop
:setWay
for /f %%a in (x) do set way=%%a
goto :eof
:dot
set dotA=☆★○●◇◆◎■△▲¤⊙
set/a dotR=%random%%%12
set dotT=!dotA:~%dotR%,1!
set/a dotl=%random%%%28+2,dotc=%random%%%29+1
if defined %dotl%_%dotc% (goto dot)
set dot=%dotl%_%dotc%
set/a dotc2=dotc+1
set "L%dotl%=!L%dotl%:~0,%dotc%!!dotT!!L%dotl%:~%dotc2%!"
goto :eof
:gameAllOver
if exist x del x
cls
echo 游戏已经结束。
goto :eof
:missionAllOver
echo.&echo.&echo.&echo.
echo.&echo.%space:~,13%恭喜
echo.&echo.%space:~,12%全部完成
endlocal
ping -w 3 127.1>nul
goto :eof
:finishlevel
cls
echo.&echo.&echo.&echo.
echo.&echo.%space:~,13%下一关
echo.&echo.%space:~,12%Next level
ping -w 2 127.1>nul
if not exist x goto :gameAllOver
call :setWay
if %way%==q goto :gameAllOver
if %way%==r goto :playAgain
goto :eof
:gameover
cls
echo.&echo.&echo.&echo.&echo.&echo.%space:~,14%完
echo.&echo.&echo.&echo.&echo.&echo.%space:~,12%Game Over
ping -w 2 127.1>nul
if not exist x goto :gameAllOver
call :setWay
if %way%==q goto :gameAllOver
:playAgain
cls
echo.&echo.&echo.&echo.&echo.&echo.%space:~,12% 再玩一次
echo.&echo.&echo.&echo.&echo.&echo.%space:~,12%play again
endlocal
set endset=
ping -w 2 127.1>nul
if not exist x goto :gameAllOver
call :setWay
if %way%==q goto :gameAllOver
set control=wsad
set/a ranC=%random%%%4
call echo %%control:~%ranC%,1%%>x
goto :newGame
::::::::::::::::::::::::::::::::::
:kzck
title 控制窗口 - 贪吃蛇
mode con cols=32 lines=6
color 31
set a1=w
set a2=s
set a3=a
set a4=d
set/a ram=%random%%%4+1
call set/p=%%a%ram%%%<nul>x
setlocal enabledelayedexpansion
:a
cls
echo w r 重来,q 退出
echo ↑
echo a←↓→d
echo s (此窗口要处于激活状态)
choice /c wsadikjlrq /n >nul
if errorlevel 10 (
if exist x (echo q>x) else del x
exit
) 2>nul
if errorlevel 9 echo r>x&goto a
if %errorlevel% gtr 4 (set/a err=%errorlevel%-4) else set err=%errorlevel%
set/p=!a%err%!<nul>x
goto a
[ Last edited by wxcute on 2008-10-10 at 21:08 ]
本帖最近评分记录
(共 1 条)
点击查看详情
| 评分人 | 分数 | 时间 |
|---|---|---|
| 523066680 | +15 | 2008-10-11 17:27 |
附件
┌───────┐
├→学习→实践→┤
└───────┘
├→学习→实践→┤
└───────┘



do (set pid=%%a)