May 10, 2018 04:35 PM
(This post was last modified: May 12, 2018 09:10 AM by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™.)
![[Image: bac5c29fcb7c7524212124384d9e8927.gif]](https://gyazo.com/bac5c29fcb7c7524212124384d9e8927.gif)
Code
@echo off & setlocal enableDelayedExpansion
if /i "%controller%" equ "enabled" if "%~1" neq "" goto :%~1
REM INITIALIZE -----------------------------------------------------------------------------
call :macros
mode 100,100
set "controller=enabled"
set "controls=WSADZX"
REM CHANGE ME
2>nul set /a "sides=%~1" || set /a "sides=4"
REM -------------
set /a "size=18"
set /a "x=50", "y=50"
set /a "angle=360 / sides"
set /a "rotationSpeed=10"
set /a "depth=10"
set /a "P_ANGLE=0"
rem Û
REM ----------------------------------------------------------------------------------------
if /i "%controller%" equ "enabled" (
if exist "%temp%\%~n0_signal.txt" del "%temp%\%~n0_signal.txt"
"%~F0" Controller %controls% >"%temp%\%~n0_signal.txt" | "%~F0" GAME_ENGINE <"%temp%\%~n0_signal.txt"
)
:GAME_ENGINE
for /l %%# in () do ( set /a "frame+=1"
rem User Controller
if /i "%controller%" equ "enabled" set "com=" & set /p "com="
if /i "!com!" equ "D" ( set /a "rotationSpeed+=5"
) else if /i "!com!" equ "A" ( set /a "rotationSpeed-=5"
) else if /i "!com!" equ "W" ( if !depth! lss 25 set /a "depth+=2", "x-=1", "y-=1"
) else if /i "!com!" equ "S" ( if !depth! gtr 5 set /a "depth-=2", "x+=1", "y+=1"
) else if /i "!com!" equ "Z" ( if !size! gtr 10 set /a "size-=3"
) else if /i "!com!" equ "X" if !size! lss 24 set /a "size+=3"
set /a "angle0+=rotationSpeed"
for %%i in (1 2) do ( for /l %%c in (1,1,%sides%) do (
set /a "b=%%c - 1" & for %%b in (!b!) do set /a "angle%%c=!angle%%b! + angle"
set /a "xoff=x", "yoff=y"
if %%i equ 1 (
set /a "x%%i_%%c=size * !cos(x):x=angle%%c! + xoff"
set /a "y%%i_%%c=size * !sin(x):x=angle%%c! + yoff"
) else (
set /a "x%%i_%%c=size * !cos(x):x=angle%%c! + (xoff + depth)"
set /a "y%%i_%%c=size * !sin(x):x=angle%%c! + (yoff + depth)"
)
)
set /a "c=sides + 1" & set /a "x%%i_!c!=x%%i_1", "y%%i_!c!=y%%i_1"
)
for %%i in (1 2) do for /l %%c in (1,1,%sides%) do (
set /a "d=%%c + 1"
for %%b in (!d!) do (
%line% !x%%i_%%c! !y%%i_%%c! !x%%i_%%b! !y%%i_%%b! %%c
set /a "connect_%%i_%%b_X=!x%%i_%%c!"
set /a "connect_%%i_%%b_Y=!y%%i_%%c!"
)
)
for /l %%c in (1,1,%sides%) do ( set /a "d=%%c + 1"
for %%b in (!d!) do (
%line% !connect_1_%%b_X! !connect_1_%%b_Y! !connect_2_%%b_X! !connect_2_%%b_Y! %%c
)
)
rem display everything using VT100 2J sequence to clear the screen first.
set "stats1=%esc%[9;5HA - Decrease rotation speed Z - Zoom out W - Increase Depth"
set "stats2=%esc%[11;5HD - Increase rotation speed X - Zoom in S - Decrease depth"
set "stats3=%esc%[13;5H Rotation Speed = !rotationSpeed!%esc%[14;5H Zoom - !size!"
set "stats4=%esc%[5;5HSides = !sides!; Point at every !angle! Degrees; Depth = !depth!"
set "statsBuffer=!stats1!!stats2!!stats3!!stats4!"
<nul set /p "=%esc%[2J!screen!!statsBuffer!"
set "screen="
)
exit
:Controller
if /i "%controller%" equ "enabled" (
for /l %%# in () do for /f "tokens=*" %%a in ('choice /c:%~2 /n') do <nul set /p ".=%%a"
)
:macros
set ^"LF=^
^" Above empty line is required - do not remove
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
for /F %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
<nul set /p "=!esc

