2016-06-14 88 views
0

所以最近我花了一段時間製作這個迷你文本遊戲。每次我嘗試運行它時,文件都是從以下方式開始的:戰鬥而不是:開始這真的很煩人,一旦你到達那裏,你甚至不能選擇戰鬥或跑步的選項。請幫忙。並且不要評判比賽。謝謝我的批量遊戲不會開始

@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! 
+0

'如果%% == 1'改爲'如果%Y%== 1'(也可用於'2')......這些後'if'行你也應該處理時,用戶輸入的任何其他情況比'1'或'2' ... – aschipfl

+0

'choice/c 12'只允許輸入1或2。見'選擇/?'。測試'如果錯誤級別1不是錯誤級別2回聲1選擇'和'如果錯誤級別2錯誤級別3回顯2選擇'。 – 2016-06-15 00:23:58

+0

感謝那些對我來說很新的東西,當我嘗試運行這個東西的時候,我直接去了:場景二,如果它在代碼中存在錯誤,或者如果我打開它錯誤。 – king1928

回答

0

好吧,有幾件事我需要告訴你。首先,如果你希望人們能夠看到批量文本,你需要給程序一個停止的理由,以便人們可以閱讀它。 A的結尾:啓動部分中,您有

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 

添加在Y之間的%的表示你想要的文件來看看變量y,看看它是否等於1或2

這應該解決您的問題,如果不只是對此發表評論。