Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion
- call :canvas 50 40
- set /a "dx=25", "dy=20", "di=!random! %% 3 - 1", "dj=!random! %% 3 - 1"
- :loop
- for /l %%a in (1,1,900) do (
- set /a "dx+=di", "dy+=dj", "di=!random! %% 3 - 1", "dj=!random! %% 3 - 1"
- call :plot !dx! !dy!
- call :showCanvas
- )
- call :updateCanvas
- if !l! neq 900 ( set /a "l+=1" & goto :loop) else exit /b
- rem ---------------------------------------------------------------------------------------
- rem All functions below this line.
- rem ---------------------------------------------------------------------------------------
- :canvas
- set /a "width=%~1 - 1", "height=%~2 - 1", "_=-1", "conWidth=width + 4", "conHeight=height + 5"
- if exist cursorpos.exe ( set "cls=cursorpos 0 0" ) else ( set "cls=cls" )
- for /l %%a in (-2,1,%width%) do set "outerBuffer=!outerBuffer!#"
- for /l %%a in (0,1,%width%) do set "widthBuffer=!widthBuffer! "
- call :updateCanvas
- mode con: cols=%conWidth% lines=%conHeight%
- goto :eof
- :updateCanvas
- for /l %%a in (0,1,%height%) do set /a "_+=1" & set "_[!_!]=%widthBuffer%"
- set "_="
- goto :eof
- :showCanvas
- %cls%
- echo=%outerBuffer%
- for /l %%a in (0,1,%height%) do echo=#!_[%%a]!#
- echo=%outerBuffer%
- goto :eof
- goto :eof
- :plot x y
- setlocal
- set /a "_x2=%~1 + 1"
- (endlocal
- set "_[%~2]=!_[%~2]:~0,%~1!.!_[%~2]:~%_x2%!"
- )
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement