【发布时间】:2017-09-27 19:59:04
【问题描述】:
所以,我一直在尝试批量制作经典的“三门”游戏,但遇到了一个问题。显然很难批量减少值?有人知道我能做什么吗?我把我的游戏主循环放在这篇文章下面。 有什么办法可以有效而紧凑地进行递减吗?谢谢!我在错误位置周围加上了引号。
:loopdeloop
color 07
set /a num=%random% %%3 +1
SET /p door=Pick a number between one and three:
if %door% EQU %num% (
color 0a
@echo Correct!
timeout /t 2 /nobreak>nul
SET /a score+=1
)
if %door% NEQ %num% (
color 0c
@echo Incorrect!
SET /a score-=1
timeout /t 1 /nobreak>nul
cls
@echo Three Doors.
@echo Behind two of these doors there are ghosts.
@echo Behind one, there is freedom.
@echo Which one will you take?
title Three Doors - Score: %score%
goto :loopdeloop
【问题讨论】:
-
第二个
IF命令缺少右括号。您的IF命令正在创建一个带括号的代码块。任何时候你需要在代码块中引用一个变量,你都需要使用延迟扩展。 ss64.com/nt/delayedexpansion.html
标签: batch-file decrement