Advertisement
Guest User

Game.bat

a guest
Jan 14th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.10 KB | None | 0 0
  1. @echo off & setlocal enableDelayedExpansion
  2.  
  3. call :init
  4.  
  5. :main
  6.     call :display
  7.     call :wasd_controls
  8. goto :main
  9.  
  10. :display
  11.     cls
  12.     if defined ol echo !ol!
  13.     set /a "x2=posX + 1"
  14.     for /l %%a in (1,1,%gridMaxHeight%) do (
  15.         set "line=!line[%%a]!"
  16.         if "%%a" equ "!posY!" set "line=!line:~0,%posX%!%char%!line:~%x2%!"
  17.         echo !line!
  18.     )
  19. goto :eof
  20.  
  21. :wasd_controls
  22.     for /f "tokens=*" %%a in ('choice /c:wasd /n') do (
  23.        
  24.         if /i "%%~a" equ "w" (
  25.             set /a "tw=posY - 1"
  26.             call :collisionCheck !tw! !posX!
  27.             if !error! equ 0 set /a "posY-=1"
  28.         )
  29.         if /i "%%~a" equ "a" (
  30.             set /a "ta=posX - 1"
  31.             call :collisionCheck !posY! !ta!
  32.             if !error! equ 0 set /a "posX-=1"
  33.         )
  34.         if /i "%%~a" equ "s" (
  35.             set /a "ts=posY + 1"
  36.             call :collisionCheck !ts! !posX!
  37.             if !error! equ 0 set /a "posY+=1"
  38.         )
  39.         if /i "%%~a" equ "d" (
  40.             set /a "td=posX + 1"
  41.             call :collisionCheck !posY! !td!
  42.             if !error! equ 0 set /a "posX+=1"
  43.         )
  44.        
  45.     )
  46.    REM if "!warp!" equ "true" (
  47.        
  48.     REM )
  49.     set "warp=false"
  50.     set "error=0"
  51.     for %%a in (tw ta ts td) do set "%%a="
  52. goto :eof
  53.  
  54. :collisionCheck
  55.     set /a "Y=%1", "X=%2", "error=0"
  56.     if    "!Line[%Y%]:~%X%,1!" equ "#" set "error=1"
  57.     if /i "!Line[%Y%]:~%X%,1!" equ "X" set "warp=true"
  58. goto :eof
  59.  
  60. :init
  61.     set  "openLib=( ren "%~nx0" orig-main.bat & ren GridLib.bat "%~nx0""
  62.     set "closeLib=ren "%~nx0" GridLib.bat & ren orig-main.bat "%~nx0" )"
  63.  
  64.     %openLib%
  65.     call :grid /E 3 "5x9" /s
  66.     call :forEachBox 2 3 "1" warps1 warp[1]
  67.     call :forEachBox 8 3 "2" warps2 warp[2]
  68.     call :forEachBox 2 5 "3" warps3 warp[3]
  69.     call :forEachBox 8 5 "4" warps4 warp[4]
  70.     call :forEachBox 5 4 "H" home1 home[1]
  71.     call :connectWarps !warps1! !warps2!
  72.     %closeLib%
  73.    
  74.     set "char=@"
  75.     set /a "posX=5", "posY=4"
  76.     set /a "c=!gridMaxWidth! + 2", "l=!gridMaxHeight! + 2"
  77.     mode con: cols=!c! lines=!l!
  78. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement