Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. @echo off & setlocal enableDelayedExpansion
  2.  
  3. call :init
  4.  
  5. :main
  6. cls
  7. echo. & echo --------------------------------------------------
  8. set /a "addOne=xPos + 1"
  9. for /l %%a in (!CAM_minY!,1,!CAM_maxY!) Do (
  10. set "currline=!line[%%a]!"
  11. if %%a equ !yPos! set "currline=!currline:~0,%xPos%!%character[1]%!currline:~%addOne%!"
  12. echo= # !currline:~%CAM_minX%,%CAM_maxX%! #
  13. )
  14. echo --------------------------------------------------
  15.  
  16. call :controls
  17.  
  18. %openLib% & call :calcFPS & %closeLib%
  19. goto :main
  20.  
  21. :init
  22. if exist orig-main.bat ren orig-main.bak.bat
  23. set "openLib=( ren "%~nx0" orig-main.bat & ren library.bat "%~nx0""
  24. set "closeLib=ren "%~nx0" library.bat & ren orig-main.bat "%~nx0" )"
  25.  
  26. set "character[1]="
  27. set "currentMap=L1.txt"
  28. set /a "PGDP=3", "PGRP=5"
  29.  
  30. %openLib% & call :getBuffer "1,1,%PGRP%" " " pushBoxesRight & %closeLib%
  31.  
  32. for /f "tokens=*" %%a in (map.txt) do (
  33. set /a "maxY+=1"
  34. set "Line[!maxY!]=%pushBoxesRight%%%~a%pushBoxesRight%"
  35. )
  36.  
  37. %openLib% & call :length !Line[%maxY%]! maxX & %closeLib%
  38.  
  39. set /a "defCAM_minY=-%PGDP%" , "defCAM_maxY=maxY + PGDP", "defCAM_minX=-%PGRP%" , "defCAM_maxX=maxX / 2"
  40. set /a "BOX_minX=PGRP + 1", "BOX_maxX=maxX + 3" , "BOX_minY=PGDP - 1", "BOX_maxY=maxY - 1"
  41. set /a "_e=maxY + 1", "_t=maxY + PGDP", "_r=maxX + PGRP - 1"
  42.  
  43. %openLib% & call :getBuffer "-%PGRP%,1,%_r%" " " emptyLineBuffer & %closeLib%
  44. for /l %%a in (-%PGDP%,1,0) do set "Line[%%a]=!emptyLineBuffer!"
  45. for /l %%a in (%_e%,1,%_t%) do set "Line[%%a]=!emptyLineBuffer!"
  46.  
  47. mode con: cols=%_r% lines=%_e%
  48. for %%a in (_e _t emptyLineBuffer) do set "%%a="
  49.  
  50. ( for %%a in ( "defaultGround=BOX_maxY" "maxJump=(defaultGround - 2)"
  51. "xPos=BOX_minX + 1" "yPos=BOX_maxY"
  52. "CAM_minY=7" "CAM_maxY=26"
  53. "CAM_minX=0" "CAM_maxX=48"
  54. ) do set /a %%a )
  55.  
  56. %openLib% & call :prep_calcFPS 100 & %closeLib%
  57. goto :eof
  58.  
  59. :controls
  60. for /f "tokens=*" %%a in ('choice /c:wasd /n') do set "move=%%a"
  61. if /i "!move!" equ "W" (
  62. set /a "CAM_minY-=1", "CAM_maxY-=1", "yPos-=1"
  63. if !CAM_minY! lss !defCAM_minY! set /a "CAM_maxY+=1", "CAM_minY=!defCAM_minY!"
  64. if !yPos! leq %BOX_minY% set "yPos=%BOX_minY%"
  65. )
  66. if /i "!move!" equ "S" (
  67. set /a "CAM_minY+=1", "CAM_maxY+=1", "yPos+=1"
  68. if !CAM_maxY! gtr !defCAM_maxY! set /a "CAM_minY-=1", "CAM_maxY=!defCAM_maxY!"
  69. if !yPos! geq %BOX_maxY% set "yPos=%BOX_maxY%"
  70. )
  71. if /i "!move!" equ "A" (
  72. set /a "CAM_minX-=1", "xPos-=1"
  73. if !CAM_minX! leq 0 set "CAM_minX=0"
  74. if !xPos! leq %BOX_minX% set "xPos=%BOX_minX%"
  75. )
  76. if /i "!move!" equ "D" (
  77. set /a "CAM_minX+=1", "xPos+=1"
  78. if !CAM_minX! gtr !defCAM_maxX! set "CAM_minX=!defCAM_maxX!"
  79. if !xPos! geq %BOX_maxX% set /a "xPos=%BOX_maxX%"
  80. )
  81. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement