Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion
- set /a "width=50 - 1", "height=40 - 1", "conWidth=width + 5", "conHeight=height + 6", "_=0"
- for /l %%a in (-2,1,%width%) do set "outerBuffer=!outerBuffer!#"
- for /l %%a in (0,1,%width%) do set "widthBuffer=!widthBuffer! "
- for /l %%a in (0,1,%height%) do set "_[%%a]=%widthBuffer%"
- if exist "%temp%\cursorpos.exe" ( set "cls="%temp%\cursorpos.exe" 0 1" ) else ( set "cls=cls" )
- mode con: cols=%conWidth% lines=%conHeight%
- set "balls=6"
- for /l %%b in (1,1,%balls%) do (
- set /a "r[%%b]=3"
- set /a "x[%%b]=!random! %% width + r[%%b]"
- set /a "y[%%b]=!random! %% height + r[%%b]"
- set /a "i[%%b]=!random! %% 3 + 1"
- set /a "j[%%b]=!random! %% 2 + 1"
- set /a "c[%%b]=%%b"
- set /a "bmaxW[%%b]=width - r[%%b]"
- set /a "bmaxH[%%b]=height - r[%%b]"
- set /a "bmin[%%b]=r[%%b]"
- )
- rem inf_loop
- for /l %%# in () do ( for /l %%b in (1,1,%balls%) do (
- set /a "x[%%b]+=i[%%b]"
- set /a "y[%%b]+=j[%%b]"
- if !x[%%b]! geq !bmaxW[%%b]! set /a "x[%%b]=bmaxW[%%b]", "i[%%b]*=-1"
- if !y[%%b]! geq !bmaxH[%%b]! set /a "y[%%b]=bmaxH[%%b]", "j[%%b]*=-1"
- if !x[%%b]! leq !bmin[%%b]! set /a "x[%%b]=bmin[%%b]", "i[%%b]*=-1"
- if !y[%%b]! leq !bmin[%%b]! set /a "y[%%b]=bmin[%%b]", "j[%%b]*=-1"
- call :plot !x[%%b]! !y[%%b]! !c[%%b]!
- call :circle !x[%%b]! !y[%%b]! !r[%%b]! .
- )
- %cls%
- echo= %outerBuffer%
- for /l %%a in (0,1,%height%) do echo= #!_[%%a]!#
- echo= %outerBuffer%
- for /l %%a in (0,1,%height%) do set "_[%%a]=%widthBuffer%"
- )
- :plot x y
- setlocal
- set "c=%~3"
- set /a "_y=%~2", "_x=%~1", "_x2=%~1 + 1"
- (endlocal
- set "_[%_y%]=!_[%_y%]:~0,%_x%!%c:~0,1%!_[%_y%]:~%_x2%!"
- )
- goto :eof
- :circle x y r
- set /a "___rr=%~3"
- for /l %%y in (-%___rr%,1,%___rr%) do for /l %%x in (-%___rr%,1,%___rr%) do (
- set /a "t=-___rr - 1", "S=(%%x * %%x) + (%%y * %%y) - (___rr * ___rr) - t - 1"
- if !S! geq !t! if !S! leq 1 (
- set /a "_x=%%x + %~1", "_y=%%y + %~2"
- set /a "_x2=_x + 1"
- call set "_[!_y!]=%%_[!_y!]:~0,!_x!%%%~4%%_[!_y!]:~!_x2!%%"
- )
- )
- for %%a in (t S _x _y _x2 ___rr) do set "%%a="
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement