我正在尝试制作自己的批处理游戏,但是当我尝试运行脚本/代码时,它会立即关闭

时间:2018-11-16 19:32:39

标签: batch-file

好的,所以我正在尝试制作批处理游戏。我已经编码/编写了菜单。因此,我尝试运行它以查看它是否有效,但它立即关闭!谁能看看代码/脚本来帮助我找出我做错了什么?

我也在使用记事本++

@echo off
title Dungeon Slayer - A Text RPG

:MainMenu
cls
echo.
echo Dungeon Slayer
echo   A Text RPG
echo.
echo  Build: A1
echo.
echo 1. Play
echo.
echo 2. Settings
echo.
echo 3. Changelog
echo.
echo 4. Exit
echo.
set /p MainMenuSelection
if /p "%MainMenuSelection%" EQU "1" goto :Play
if /p "%MainMenuSelection%" EQU "2" goto :Settings
if /p "%MainMenuSelection%" EQU "3" goto :Changelog
if /p "%MainMenuSelection%" EQU "4" goto :Exit
goto :MainMenu

:Play
cls
echo.
echo Currently Gameplay Development has not been started.
echo.
pause
goto :MainMenu

:Settings
cls
echo.
echo Currently we have not made any settings.
echo.
pause
goto :MainMenu

:Changelog
cls
echo.
echo 11/16/2018
echo.
echo -A1 Build Released
echo.
pause
goto :MainMenu 

:Exit
cls
exit

1 个答案:

答案 0 :(得分:0)

下面是使用Choice的示例。

@Echo Off
Set "Build=A1"
Set "BDate=11/16/2018"
Set "GName=Dungeon Slayer"
Set "GDesc=A Text RPG"
Title %GName% - %GDesc%

:MainMenu
ClS
Echo=
Echo=%GName%
Echo=%GDesc%
Echo=
Echo Build: %Build%
Echo=
Echo 1. Play
Echo=
Echo 2. Settings
Echo=
Echo 3. Changelog
Echo=
Echo 4. Exit
Echo=
Choice /C 1234 /M "Which item"
If ErrorLevel 4 Exit /B
If ErrorLevel 3 GoTo ChangeLog
If ErrorLevel 2 GoTo Settings

:Play
ClS
Echo=
Echo Sorry, gameplay development has not yet started.
Echo=
Timeout 3 >Nul
GoTo MainMenu

:Settings
ClS
Echo=
Echo Sorry, we are yet to create any settings.
Echo=
Timeout 3 >Nul
GoTo MainMenu

:ChangeLog
ClS
Echo=
Echo=%BDate%
Echo=
Echo -%Build% Build Released
Echo=
Timeout 3 >Nul
GoTo MainMenu