游戏中5秒打字挑战
Typing challenge in 5 seconds in game
我正在用批处理文件做一个角色扮演游戏,我想挑战用户在 5 秒内输入“黄油”之类的词。如果他不打算这样做,他将一无所获并返回。但如果他打字正确,他就会赚到钱。我希望它显示计时器。你们能帮忙吗?可以用PING命令完成吗?
算你的努力,你不配。
只是给你一个起点,
批次在 measuring/handling/calculating 时间内不好。
:: Q:\Test18\typingtest.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
:loop
cls
Echo enter butter
choice /n /C b >NUL
set start=%time%
choice /n /C u >NUL
choice /n /C t >NUL
choice /n /C t >NUL
choice /n /C e >NUL
choice /n /C r >NUL
set ready=%time%
Echo start:%start%
Echo ready:%ready%
示例输出:
enter butter
start:21:00:50,50
ready:21:00:51,56
尽管我最初发表评论,但以下版本更通用并且可以正确计算秒数,前提是您的 %time%
重新调整 24 小时格式和百秒。
:: Q:\Test18\typingtest.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
cls
Echo enter butter
Set "Start="
For %%A in (b u t t e r) do (
choice /n /C %%A >NUL
if not defined Start Set "Start=%time%"
)
Set "Ready=%time%"
Call :CalcTime Start
Call :CalcTime Ready
Set /A "Lapse=Ready-Start"
Echo Secs : %Lapse:~0,-2%,%Lapse:~-2%
Pause
Goto :Eof
:CalcTime
Echo=%1: !%1!
For /f "tokens=1-4delims=:.," %%H in ("!%1!"
) Do Set /A "%1=(1%%H-100)*360000+(1%%I-100)*6000+(1%%J-100)*100+%%K"
示例输出:
enter butter
Start: 16:25:43,42
Ready: 16:25:46,94
Secs : 3,52
我正在用批处理文件做一个角色扮演游戏,我想挑战用户在 5 秒内输入“黄油”之类的词。如果他不打算这样做,他将一无所获并返回。但如果他打字正确,他就会赚到钱。我希望它显示计时器。你们能帮忙吗?可以用PING命令完成吗?
算你的努力,你不配。
只是给你一个起点,
批次在 measuring/handling/calculating 时间内不好。
:: Q:\Test18\typingtest.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
:loop
cls
Echo enter butter
choice /n /C b >NUL
set start=%time%
choice /n /C u >NUL
choice /n /C t >NUL
choice /n /C t >NUL
choice /n /C e >NUL
choice /n /C r >NUL
set ready=%time%
Echo start:%start%
Echo ready:%ready%
示例输出:
enter butter
start:21:00:50,50
ready:21:00:51,56
尽管我最初发表评论,但以下版本更通用并且可以正确计算秒数,前提是您的 %time%
重新调整 24 小时格式和百秒。
:: Q:\Test18\typingtest.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
cls
Echo enter butter
Set "Start="
For %%A in (b u t t e r) do (
choice /n /C %%A >NUL
if not defined Start Set "Start=%time%"
)
Set "Ready=%time%"
Call :CalcTime Start
Call :CalcTime Ready
Set /A "Lapse=Ready-Start"
Echo Secs : %Lapse:~0,-2%,%Lapse:~-2%
Pause
Goto :Eof
:CalcTime
Echo=%1: !%1!
For /f "tokens=1-4delims=:.," %%H in ("!%1!"
) Do Set /A "%1=(1%%H-100)*360000+(1%%I-100)*6000+(1%%J-100)*100+%%K"
示例输出:
enter butter
Start: 16:25:43,42
Ready: 16:25:46,94
Secs : 3,52