Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion
- call :init
- :main
- call :display
- call :wasd_controls
- goto :main
- :display
- cls
- if defined ol echo !ol!
- set /a "x2=posX + 1"
- for /l %%a in (1,1,%gridMaxHeight%) do (
- set "line=!line[%%a]!"
- if "%%a" equ "!posY!" set "line=!line:~0,%posX%!%char%!line:~%x2%!"
- echo !line!
- )
- goto :eof
- :wasd_controls
- for /f "tokens=*" %%a in ('choice /c:wasd /n') do (
- if /i "%%~a" equ "w" (
- set /a "tw=posY - 1"
- call :collisionCheck !tw! !posX!
- if !error! equ 0 set /a "posY-=1"
- )
- if /i "%%~a" equ "a" (
- set /a "ta=posX - 1"
- call :collisionCheck !posY! !ta!
- if !error! equ 0 set /a "posX-=1"
- )
- if /i "%%~a" equ "s" (
- set /a "ts=posY + 1"
- call :collisionCheck !ts! !posX!
- if !error! equ 0 set /a "posY+=1"
- )
- if /i "%%~a" equ "d" (
- set /a "td=posX + 1"
- call :collisionCheck !posY! !td!
- if !error! equ 0 set /a "posX+=1"
- )
- )
- REM if "!warp!" equ "true" (
- REM )
- set "warp=false"
- set "error=0"
- for %%a in (tw ta ts td) do set "%%a="
- goto :eof
- :collisionCheck
- set /a "Y=%1", "X=%2", "error=0"
- if "!Line[%Y%]:~%X%,1!" equ "#" set "error=1"
- if /i "!Line[%Y%]:~%X%,1!" equ "X" set "warp=true"
- goto :eof
- :init
- set "openLib=( ren "%~nx0" orig-main.bat & ren GridLib.bat "%~nx0""
- set "closeLib=ren "%~nx0" GridLib.bat & ren orig-main.bat "%~nx0" )"
- %openLib%
- call :grid /E 3 "5x9" /s
- call :forEachBox 2 3 "1" warps1 warp[1]
- call :forEachBox 8 3 "2" warps2 warp[2]
- call :forEachBox 2 5 "3" warps3 warp[3]
- call :forEachBox 8 5 "4" warps4 warp[4]
- call :forEachBox 5 4 "H" home1 home[1]
- call :connectWarps !warps1! !warps2!
- %closeLib%
- set "char=@"
- set /a "posX=5", "posY=4"
- set /a "c=!gridMaxWidth! + 2", "l=!gridMaxHeight! + 2"
- mode con: cols=!c! lines=!l!
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement