我的批量游戏不会启动

时间:2016-06-14 23:50:29

标签: batch-file

所以最近我花了一段时间制作这个迷你文字游戏。每次我尝试运行它时,文件只是从以下开始:战斗而不是:开始tis真的很烦人,一旦你到达那里你甚至无法选择战斗或跑步的选项。请帮忙。并且不要判断游戏。感谢

@echo off
title: My game!
color 0a
:loop
echo My game!
cls
goto Start
:Start
cls color 3c
echo Hello welcome to my game If this works.....
cls
echo before you start the game make sure that you turned of the hair curler,
echo didnt leave your keys in the car and locked the front door, and THEN you have to make
echo sure that you ARE READY
cls
color 0c
echo WHAT ARE YOU DOING HERE!?!
echo Get out!
color 09
echo A giant monster aproaches you, you dont stop to see what it is chasing you.
color 0c
echo Im gonna demolish you!!
cls
color 09
echo you stop running, the monster is far behind you.You look around and  you are in
echo some kind of dungeon
echo then you start to wonder if you could actually try and fight this thing!
cls
color 09
echo Options
echo 1 try and fight this darn thing!
echo 2 keep running
set /p y=
if %% == 1 goto fight
if %% == 2 goto run

:fight
cls
color 09
echo suddenly you find a pocket nife in your cargo jeans! Very conveniant am i right?
echo so you run up to the monster and slay it!
goto scene two

:run
echo youtire quickly and the monster catches up and swiftly kills you
goto GAME OVER

:GAME OVER
wow nice job you managed to die on the first level
echo Options
echo 1 Try again!
echo 2 Be a wuss and quit
set /p y=
if %% == 1 goto Start
if %% == 2 goto quitter

:quitter
cls
color 09
echo Nice job quitter.

:scene two
color 09
echo wow nice job!
echo so far you have done a nice job!

1 个答案:

答案 0 :(得分:0)

好的,我需要告诉你一些事情。首先,如果您希望人们能够批量查看文本内容,您需要为程序提供一个停止的理由,以便人们可以阅读它。结束:开始部分你有

set /p y=

这给程序一个停止的理由,因为它正在等待用户输入某种输入,但是你希望你也可以使用。

pause <nul 

然后

set /p y=

你有

if %% == 1 goto fight
if %% == 2 goto run

除了一件事,这几乎都是精致和花花公子。你忘了把y放在%%之间。

应该是这样的。

if %y% == 1 goto fight
if %y% == 2 goto run

在%'s之间添加y表示您希望文件查看变量y并查看它是否等于1或2.

这应该可以解决您的问题,如果不是对此进行评论。