2014-10-28 60 views

回答

2

dbenham製作的蛇碼非常複雜,但是由於你的問題僅限於輸入機制,所以它不是問題。

這個蛇遊戲使用choice命令,只需要按下指定的按鍵,沒有按下按鍵。根據用戶按下的鍵,變量errorlevel將被更改爲選項列表中該字符的數字位置。

類型choice /?幫助屏幕。下面是摘錄:

CHOICE [/C choices] [/N] [/CS] [/T timeout /D choice] [/M text] 

Description: 
    This tool allows users to select one item from a list 
    of choices and returns the index of the selected choice. 

Parameter List: 
    /C choices  Specifies the list of choices to be created. 
         Default list is "YN". 

    /N     Hides the list of choices in the prompt. 
         The message before the prompt is displayed 
         and the choices are still enabled. 

    /CS     Enables case-sensitive choices to be selected. 
         By default, the utility is case-insensitive. 

    /T timeout  The number of seconds to pause before a default 
         choice is made. Acceptable values are from 0 to 
         9999. If 0 is specified, there will be no pause 
         and the default choice is selected. 

    /D choice  Specifies the default choice after nnnn seconds. 
         Character must be in the set of choices specified 
         by /C option and must also specify nnnn with /T. 

    /M text   Specifies the message to be displayed before 
         the prompt. If not specified, the utility 
         displays only a prompt. 

    /?     Displays this help message. 

下面是一個例子:

C:\> set errorlevel=-1 
C:\> choice /c "YN" /m "Yes or No" 
Yes or No: [Y,N]? Y 

C:\> Echo %errorlevel% 
1 

C:\> 
+0

Snake.bat使用'輸入XCOPY/w'爲2.0 – SomethingDark 2014-10-29 01:00:59

+0

是版本,但由於運明確表示,他是一個初學者我以爲我會給他「選擇」命令,因爲它更簡單。無論如何,感謝您撿起它。 – Monacraft 2014-10-29 01:33:44

+0

謝謝你的記住我有點小事,但你能解釋一下錯誤級別是什麼嗎?我試圖查找它,但顯然它有點複雜,請告訴我xcopy是什麼,謝謝! – Cool841 2014-10-29 08:56:06

相關問題