::::::放入文件open.bat
@echo off
start direction.bat
title made by 523066680
:action
color 07
setlocal enabledelayedexpansion
mode con cols=65 lines=35
for /l %%a in (1,1,60) do (set space= !space!)
for /l %%a in (1,1,30) do (set L%%a=%space%)
set /a line=15,col=29,i=0,long=9
:loop
:::::::::::::::控制蛇長,判斷是否建立食物部分
if %i% lss %long% (set /a i+=1) else (set i=1)
if defined cut%i% (
if not defined dot (call :dot)
!cut%i%:"=!
set "L%a%=!L%a%:~0,%b%! !L%a%:~%c%!"
set "%a%_%b%="
)
:pausego
:::::::顯示
cls
echo, %space: =_%__
for /l %%a in (1,1,30) do echo,│!L%%a!│
echo, %space: =-%--
echo,- 分?jǐn)?shù):%fen%00 %echo%
for /l %%a in (1,1,3) do (ping -n 1 127.0>nul)
::::::::::::::::讀取數(shù)據(jù),分析部分
:typex
set /p way=<x
if %way%==q (exit)
if %way%==r (endlocal &set echo=按wasd方向鍵激活。&goto :action) else (set echo=)
if %way%==p (ping -n 2 127.0>nul &set echo=按wasd方向鍵激活。&goto :pausego) else (set echo=)
if %way%==w (set /a line-=1)
if %way%==s (set /a line+=1)
if %way%==a (set /a col-=1)
if %way%==d (set /a col+=1)
if defined %line%_%col% (goto :gameover)
if %line% equ 31 (goto :gameover)
if %line% equ 0 (goto :gameover)
if %col% equ -1 (goto :gameover)
if %col% equ 60 (goto :gameover)
:::::::::::::::設(shè)置部分,描點,記錄點坐標(biāo)。
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+=3,fen+=1 &set dot=)
goto :loop
::::::::::::建立食物O的調(diào)用部分
:dot
set /a dotl=%random%%%28+2,dotc=%random%%%58+1
if defined %dotl%_%dotc% (goto :dot)
set dot=%dotl%_%dotc%
set /a dotc2=dotc+1
set "L%dotl%=!L%dotl%:~0,%dotc%!O!L%dotl%:~%dotc2%!"
goto :eof
:gameover
echo,p>x
color 0a
ping -n 2 127.0>nul
cls
echo,game over 在控制臺按q結(jié)束游戲,r再玩一次,然后按任意方向鍵激活暫停狀態(tài)
ping -n 3 127.0>nul
endlocal
goto :action
::::::::::::::::::放入文件direction.bat
@echo off &mode con cols=35 lines=8
setlocal enabledelayedexpansion
echo,p>x
for %%a in (w a s d p q) do (set de%%a=defined)
set _w=s
set _s=w
set _a=d
set _d=a
set notequ=have
:a
cls
set /p input="w a s d q(退出) r(重來) p(暫停):"
if "%input%"=="q" (
echo,q>x
exit
)
if "%input%"=="r" (
echo,r>x
)
if "%input%"=="%notequ%" (goto :a)
if not defined de%input% (goto :a)
set notequ=!_%input%!
echo %input%>x
goto :a
雙擊open.bat 即可開始游戲
聯(lián)系客服