:这时候出乎意料。批处理脚本

问题描述 投票:0回答:2
@echo off
TITLE The Fighters
color 04
menu
cls
echo.
echo.
echo.
echo  ###  ######   #####  #   #  #######  #####   ######
echo  #      #      #      #   #     #     #       #     #
echo  ###    #      # ###  #####     #     #####   #######    
echo  #      #      #   #  #   #     #     #       #   #
echo  #      #      #   #  #   #     #     #       #    #
echo  #    ######   #####  #   #     #     #####   #     #
echo.
echo     Developed By:
echo.           
echo.
echo        1). Start Game
echo        2). Help
echo        3). Exit
echo.
echo.
echo.
echo.
echo.
echo                    Alpha 2.0
set /p number=

if %number%== 1 goto fight
if %number%== 2 goto help
if %number%== 3 exit

:fight
cls
echo Welcome to the Fighting Arena.
echo Press 1,2, or 3 to fight an enemy.
echo.
echo.
echo.
echo   _____________________
echo  |                     |-
echo -|                     |
echo  |                     |-
echo -|                     |
echo  |                     |-
echo -|                     |-
echo  |                     |
echo -|                     |-
echo  |                     |
echo -|                     |-
echo  |                     |
echo -|                     |-
echo  |_____________________|

我不知道为什么......但是当我点击1时它说:此时是意外的。 如果有人能回答这个问题,我将非常感激。 还... 请不要窃取我的代码;-;

这是我制作的小游戏。使用记事本。这相当容易。

batch-file cmd
2个回答
0
投票

|是批处理文件中的特殊字符(用于输出重定向或用于条件执行)。将所有

|
更改为
^|
.

也考虑使用

MODE
命令:

@echo off
TITLE The Fighters
color 04
rem ----
mode con cols=80 lines=50
rem ----
menu
cls
echo.
echo.
echo.
echo  ###  ######   #####  #   #  #######  #####   ######
echo  #      #      #      #   #     #     #       #     #
echo  ###    #      # ###  #####     #     #####   #######    
echo  #      #      #   #  #   #     #     #       #   #
echo  #      #      #   #  #   #     #     #       #    #
echo  #    ######   #####  #   #     #     #####   #     #
echo.
echo     Developed By: RyeGuyXD
echo.           
echo.
echo        1). Start Game
echo        2). Help
echo        3). Exit
echo.
echo.
echo.
echo.
echo.
echo                    Alpha 2.0
set /p number=

if %number%== 1 goto fight
if %number%== 2 goto help
if %number%== 3 exit

:fight
cls
echo Welcome to the Fighting Arena.
echo Press 1,2, or 3 to fight an enemy.
echo.
echo.
echo.
echo   _____________________
echo  ^|                     ^|-
echo -^|                     ^|
echo  ^|                     ^|-
echo -^|                     ^|
echo  ^|                     ^|-
echo -^|                     ^|-
echo  ^|                     ^|
echo -^|                     ^|-
echo  ^|                     ^|
echo -^|                     ^|-
echo  ^|                     ^|
echo -^|                     ^|-
echo  ^|_____________________^|
pause >nul
goto :fight

0
投票

这将使它更健壮:

:menu
cls

echo                    Alpha 2.0
set "number="
set /p "number=Enter 1,2 or 3 : "

if "%number%"=="1" goto fight
if "%number%"=="2" goto help
if "%number%"=="3" exit
goto :menu

:fight
© www.soinside.com 2019 - 2024. All rights reserved.