所以我正在搞乱批处理,并编写了这个脚本:
@echo off
setlocal enabledelayedexpansion
set /a "start=33"
set "sc1=°"
set "sc2=°"
set "sc3=°"
set "sc4=°"
set "sc5=°"
set "sc6= "
set "sc7= "
set "sc8= "
set "sc9= "
set "sc10= "
set "sc11= "
set "sc12= "
set "sc13= "
set "sc14= "
set "sc15= "
set "sc16= "
set "sc17= "
set "sc18= "
set "sc19= "
set "sc20= "
set "sc21= "
set "sc22= "
set "sc23=°"
set "sc24= "
set "sc25= "
set "sc26= "
set "sc27= "
set "sc28= "
set "sc29= "
set "sc30= "
set "sc31= "
set "sc32= "
set "sc33=X"
set "sc34= "
set "sc35= "
set "sc36= "
set "sc37= "
set "sc38= "
set "sc39= "
set "sc40= "
set "sc41= "
set "sc42= "
set "sc43= "
set "sc44= "
set "sc45= "
set "sc46= "
set "sc47= "
set "sc48= "
set "sc49= "
set "sc50= "
set "sc51= "
set "sc52= "
set "sc53= "
set "sc54= "
set "sc55= "
:display
cls
echo. !sc1!!sc2!!sc3!!sc4!!sc5!
echo. !sc6!!sc7!!sc8!!sc9!!sc10!
echo. !sc11!!sc12!!sc13!!sc14!!sc15!
echo. !sc16!!sc17!!sc18!!sc19!!sc20!
echo. !sc21!!sc22!!sc23!!sc24!!sc25!
echo. !sc26!!sc27!!sc28!!sc29!!sc30!
echo. !sc31!!sc32!!sc33!!sc34!!sc35!
echo. !sc36!!sc37!!sc38!!sc39!!sc40!
echo. !sc41!!sc42!!sc43!!sc44!!sc45!
echo. !sc46!!sc47!!sc48!!sc49!!sc50!
echo. !sc51!!sc52!!sc53!!sc54!!sc55!
choice /c wasd
if !ERRORLEVEL!==1 (
set /a "x=5"
set "op=-"
)
if !ERRORLEVEL!==2 (
set /a "x=1"
set "op=-"
)
if !ERRORLEVEL!==3 (
set /a "x=5"
set "op=+"
)
if !ERRORLEVEL!==4 (
set /a "x=1"
set "op=+"
)
call :detect
if !m! EQU 1 (
goto :display
)
set /a "newstart=!start!!op!!x!"
set "sc!newstart!=X"
set "sc!start!= "
set /a "start=!newstart!"
goto :display
:detect
set /a "detect=!start!!op!!x!"
if !sc%detect%!==° (
set /a "m=1"
)
exit /b
所有这些都是批量游戏的简单原型。你可以用wasd向各个方向移动。我唯一的问题是当你按下一个按钮靠墙时,你会被永久卡住。我该如何解决这个问题?
答案 0 :(得分:2)
您的检测工作正常。你的问题是你永远不清楚" m"检测到碰撞后的值,因此卡住了。最简单的解决方法是在:detect例程的开头简单地将m初始化为0。