我已经制作了这个菜单来选择东西,但是如果我选择了它就会崩溃 我不知道为什么。它必须是代码中的错误,但这部分对我来说相当新,所以我自己无法找到错误。 继承人代码:
@echo off
title Tic Tac Toe
set "22= "
set "23= "
set "24= "
set "32= "
set "33= "
set "34= "
set "42= "
set "43= "
set "44= "
set "pos1=22"
:Start
color f0
cls
echo ßßÛßß °ß° Ûßß ßßÛßß ÛßßÛ Ûßß ßßÛßß ÛßßÛ Ûßß
echo °±Û°° ßÛß Û°° °±Û°° ÛÜÜÛ Û°° °±Û°° Û°°Û Ûßß
echo °±Û°° ßßß ßßß °±Û°° ß°°ß ßßß °±Û°° ßßßß ßßß
echo by SpoodyTheone
ping localhost -n 5 >nul
:menuSTART1
color 06
cls
echo ---------------------------------------------------------------------------
echo ^| ßßÛßß °ß° Ûßß ßßÛßß ÛßßÛ Ûßß ßßÛßß ÛßßÛ Ûßß ^|
echo ^| °±Û°° ßÛß Û°° °±Û°° ÛÜÜÛ Û°° °±Û°° Û°°Û Ûßß ^|
echo ^| °±Û°° ßßß ßßß °±Û°° ß°°ß ßßß °±Û°° ßßßß ßßß ^|
echo ---------------------------------------------------------------------------
echo PRESS E TO SELECT
echo START^<
echo HELP
echo EXIT
:: Selection
choice /c:EWS >nul
if "%errorlevel%"=="1" goto game
if "%errorlevel%"=="2" goto menuSTART3
if "%errorlevel%"=="3" goto menuSTART2
:menuSTART2
color 06
cls
echo ---------------------------------------------------------------------------
echo ^| ßßÛßß °ß° Ûßß ßßÛßß ÛßßÛ Ûßß ßßÛßß ÛßßÛ Ûßß ^|
echo ^| °±Û°° ßÛß Û°° °±Û°° ÛÜÜÛ Û°° °±Û°° Û°°Û Ûßß ^|
echo ^| °±Û°° ßßß ßßß °±Û°° ß°°ß ßßß °±Û°° ßßßß ßßß ^|
echo ---------------------------------------------------------------------------
echo PRESS E TO SELECT
echo START
echo HELP^<
echo EXIT
:: Selection
choice /c:EWS >nul
if "%errorlevel%"=="1" goto help
if "%errorlevel%"=="2" goto menuSTART1
if "%errorlevel%"=="3" goto menuSTART3
:menuSTART3
color 06
cls
echo ---------------------------------------------------------------------------
echo ^| ßßÛßß °ß° Ûßß ßßÛßß ÛßßÛ Ûßß ßßÛßß ÛßßÛ Ûßß ^|
echo ^| °±Û°° ßÛß Û°° °±Û°° ÛÜÜÛ Û°° °±Û°° Û°°Û Ûßß ^|
echo ^| °±Û°° ßßß ßßß °±Û°° ß°°ß ßßß °±Û°° ßßßß ßßß ^|
echo ---------------------------------------------------------------------------
echo PRESS E TO SELECT
echo START
echo HELP
echo EXIT^<
:: Selection
choice /c:EWS >nul
if "%errorlevel%"=="1" exit
if "%errorlevel%"=="2" goto menuSTART2
if "%errorlevel%"=="3" goto menuSTART1
:help
cls
echo.
echo CONTROLS
echo -------------------------
echo ^|WASD to move the marker^|
echo ^| E to place ^|
echo -------------------------
echo.
echo OBJECTIVE
echo -------------------------
echo ^| get 3 in a row to win ^|
echo -------------------------
pause >nul
goto menuSTART1
:game
if %rpos1% LSS 22 set "rpos1=42"
if %rpos1% GTR 44 set "rpos1=24"
set "rpos1=X "
cls
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
echo Û%42%Û Û%43%Û Û%44%Û
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
echo.
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
echo Û%32%Û Û%33%Û Û%34%Û
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
echo.
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
echo Û%22%Û Û%23%Û Û%24%Û
echo ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ
choice /c:WASDE >nul
if "%errorlevel%"=="1" goto ad10
if "%errorlevel%"=="2" goto re1
if "%errorlevel%"=="3" goto re10
if "%errorlevel%"=="4" goto ad1
if "%errorlevel%"=="5" goto sel
::add and subtract
:ad10
set /a "rpos1=+10"
goto game
:re1
set /a "rpos1=-1"
goto game
:re10
set /a "rpos=-10"
goto game
:ad1
set /a "rpos1=+1"
答案 0 :(得分:1)
问题在于这一行,在游戏中:
if %rpos1% LSS 22 set "rpos1=42"
rpos1
最初是未定义的,因为您没有引号,它会对任何内容进行评估。