返回列表 发帖

[游戏娱乐] 【首发:INAG论坛】批处理推箱子游戏

【更新:编写地图时支持已有箱子的目标(★),详情键回帖】
链接: https://pan.baidu.com/s/1OW0lslV6SNTaSjcxf50ivw 提取码: vfsc

刚刚更新 解决地图太小无法正常显示的BUG。
小弟不才 界面不太漂亮 还望高手指点~
支持自编地图,游戏说明:█为墙 ▓为箱子 ☆为目标 ♀为人的位置。控制方法:WSAD移动小人 46跳关 E退出 R重来
目录下有一个map.bat是自编地图用的 用鼠标控制 方法不多说了。本程序需要外部命令行程序Cmos.exe和Choice.exe。附件里有。
挂上代码:
推箱子.bat:
@echo off&setlocal enabledelayedexpansion
if not exist choice.exe echo 找不到choice.exe!&pause&exit
set file=1
:begin
if not exist level%file%.txt echo 找不到第%file%关!&pause&exit
title%file%
cls
echo 正在加载……
for /f %%a in (level%file%.txt) do (set aline=%%a)
set zs=0
set y=0
set mbs=0
:next
if "!aline:~%zs%!"=="" goto alinelast
set /a zs=%zs%+1
goto next
:alinelast
for /f %%a in (level%file%.txt) do (set /a y=y+1
set aline=%%a
for /l %%b in (1 1 %zs%) do (call :sets %%b !y!)
)
set /a czs=%zs%*2+1
if %czs% leq 14 set czs=14
mode con:cols=%czs% lines=%y%
:loop
cls
set nmb=
for /l %%y in (1 1 %y%) do (
for /l %%x in (1 1 %zs%) do (set /p=!x%%xy%%y!<nul
for /l %%a in (1 1 %mbs%) do (if !mbx%%a!==%%x (if !mbx%%a!==%%x (if !mby%%a!==%%y (set/p=<nul
set mb=☆
if "!x%%xy%%y!"=="▓" set mb=★
if !mb!==☆ set nmb=1
set/p=!mb!<nul))))
if %%x==%psx% (if %%y==%psy% (set psd=1
set/p=<nul
set/p=♀<nul)))
if not %%y==%y% echo.
)
if "%nmb%"=="" goto win
choice /c WSAD46ER /n>nul
set movex=0
set movey=0
set cnm=0
if %errorlevel%==1 (set movey=-1)
if %errorlevel%==2 (set movey=1)
if %errorlevel%==3 (set movex=-1)
if %errorlevel%==4 (set movex=1)
if %errorlevel%==5 (call :cleanarchives
set /a file=%file%-1
goto begin)
if %errorlevel%==6 (call :cleanarchives
set /a file=%file%+1
goto begin)
if %errorlevel%==7 exit
if %errorlevel%==8 (call :cleanarchives
goto begin)
set /a npsx=%movex%+%psx%
set /a npsy=%movey%+%psy%
if "!x%npsx%y%npsy%!"=="" set cnm=1
if "!x%npsx%y%npsy%!"=="█" set cnm=1
if "!x%npsx%y%npsy%!"=="▓" (call :movewall)
if "%cnm%"=="1" goto loop
set psx=%npsx%
set psy=%npsy%
goto :loop
::==========================
goto :eof
:sets
set/a sx=%1-1
set x%1y%2=!aline:~%sx%,1!
if "!aline:~%sx%,1!"=="♀" (set x%1y%2=
set psx=%1
set psy=%2)
if "!aline:~%sx%,1!"=="☆" (set x%1y%2=
set /a mbs=!mbs!+1
set mbx!mbs!=%1
set mby!mbs!=%2)
goto :eof
:movewall
set /a wpsx=%movex%*2+%psx%
set /a wpsy=%movey%*2+%psy%
if not "!x%wpsx%y%wpsy%!"=="" (set cnm=1&goto :eof)
set x!wpsx!y!wpsy!=▓
set x%npsx%y%npsy%=
goto :eof
:win
cls
echo 你赢了!
pause
call :cleanarchives
set /a file=%file%+1
goto begin
goto :eof
:cleanarchives
for /l %%y in (1 1 %y%) do (for /l %%x in (1 1 %zs%) do (set x%%xy%%y=))
goto :eofCOPY
自编地图:
@echo off&setlocal enabledelayedexpansion
if not exist cmos.exe echo 找不到cmos.exe!&pause&exit
set /p mx=请输入地图长度:
set /p my=请输入地图宽度:
set nowct=空白&set nowc=
set /a cmx=%mx%*2+1
set /a cmy=%my%+4
if %mx% lss 12 set cmx=25
mode con:cols=%cmx% lines=%cmy%
for /l %%y in (1 1 %my%) do (for /l %%x in (1 1 %mx%) do (set x%%xy%%y=))
:loop
cls
for /l %%y in (1 1 %my%) do (for /l %%x in (1 1 %mx%) do (set/p=!x%%xy%%y!<nul
if "%psx%"=="%%x" (if "%psy%"=="%%y" (set/p=<nul
set/p=♀<nul)))
echo.)
set /a kgs=%cmx%/2-4
set kg=
for /l %%a in (1 1 %kgs%) do (set kg=!kg!=)
echo.%kg%单击选择%kg%
echo.墙  空白  目标  箱子  人
echo.当前选择:!nowct!
set/p=保存地图<nul
cmos 0 1 -1
set /a P=%errorlevel%
set /a mouseX=%P:~0,-3%
set /a mouseY=%P%-1000*%mouseX%
set /a setx=%mousex%+1
set /a sety=%my%+2
set /a savey=%my%+4
set /a setx=%setx%/2
if "%mousey%"=="%savey%" (if %setx% leq 4 goto save)
if "%mousey%"=="%sety%" (
if !setx!==1 set nowct=墙&set nowc=█
if !setx!==3 set nowct=空白&set nowc=
if !setx!==4 set nowct=空白&set nowc=
if !setx!==6 set nowct=目标&set nowc=☆
if !setx!==7 set nowct=目标&set nowc=☆
if !setx!==9 set nowct=箱子&set nowc=▓
if !setx!==10 set nowct=箱子&set nowc=▓
if !setx!==12 set nowct=人&set nowc=♀
)
if %setx%==%psx% (if %mousey%==%psy% goto loop)
if "!x%setx%y%mousey%!"=="" goto loop
if "%nowct%"=="人" (if not "!x%setx%y%mousey%!"=="" goto loop
set psx=%setx%
set psy=%mousey%) else (set x%setx%y%mousey%=%nowc%)
goto loop
:save
mode con:cols=30 lines=3
set mbs=0
set boxes=0
set goon=0
if "%psx%"=="" echo 警告!&echo 未设定人位置 是否继续?&call :choicegoon
if !goon!==1 goto reedit
cls
for /l %%y in (1 1 %my%) do (for /l %%x in (1 1 %mx%) do (if !x%%xy%%y!==☆ set /a mbs=!mbs!+1
if !x%%xy%%y!==▓ set /a boxes=!boxes!+1
))
if not %mbs%==%boxes% (echo 警告!&echo 目标数不等于箱子数 是否继续?&call :choicegoon
if !goon!==1 goto reedit)
cls
set /p filename=请输入文件名:
type nul>%filename%
for /l %%y in (1 1 %my%) do (for /l %%x in (1 1 %mx%) do (
if "%psx%"=="%%x" (if "%psy%"=="%%y" (set/p=♀<nul>>%filename%&set wdps=1))
if "!wdps!"=="" (set/p=!x%%xy%%y!<nul>>%filename%) else (set wdps=))
if not %%y==%my% echo.>>%filename%)
goto :eof
:choicegoon
set/p=是  否<nul
:cloop
cmos 0 1 -1
set /a P=%errorlevel%
set /a mouseX=%P:~0,-3%
set /a mouseY=%P%-1000*%mouseX%
set /a setx=%mousex%+1
set /a setx=%setx%/2
if %mousey%==3 (if %setx%==1 set goon=0&goto :eof
if %setx%==3 set goon=1&goto :eof)
goto cloop
:reedit
mode con:cols=%cmx% lines=%cmy%
goto loopCOPY
1

评分人数

感谢分享

TOP

不错不错,看了下,收藏了

TOP

膜拜LZ,学习学习

TOP

最近更新:编写地图时支持已有箱子的目标(★),这下完美了

TOP

回复 1# zcydez


    万分感谢你的分享

TOP

返回列表