Jul 22, 2016 02:26 PM
(This post was last modified: Jul 22, 2016 07:55 PM by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™.)
Hey everyone, just a proof of concept I made. This is a script that can generate it's own maps based off of template files.
You can use A and D to scroll left and right.
NOTE: CHANGE TO ANSI ENCODING (uses alt+219 ascii character)
Source:
Spoiler (Click to View)
NOTE: IT IS IMPORTANT TO NAME THESE FILES AS LISTED, AND PLACED INTO A FOLDER CALLED "MAPS"(case insensitive) IN THE SAME DIRECTORY AS THE SCRIPT.
Spoiler (Click to View)
Template001.txt
Template002.txt
Template003.txt
You can use A and D to scroll left and right.
NOTE: CHANGE TO ANSI ENCODING (uses alt+219 ascii character)
Source:
Spoiler (Click to View)
Code
@echo off & setlocal enableDelayedExpansion
call :init
:main
call :display
call :controls
goto :main
:display
cls&echo.
echo Û!out!Û
for /l %%a in (1,1,!maxY!) do echo= Û!line[%%a]:~%$_%,%_$%!Û
echo Û!out!Û
goto :eof
:controls
for /f "tokens=*" %%a in ('choice /c:ad /n') do (
if /i "%%a" equ "D" if !$_! leq !maxCam! set /a "$_+=1"
if /i "%%a" equ "A" if !$_! geq 1 set /a "$_-=1"
)
goto :eof
:generateImage
rem pick a template
set /a "pickTemplate=!random! %% numberOfTemplates + 1"
rem concatenate to line[%%a]
for /l %%a in (1,1,!maxY!) do set "line[%%a]=!line[%%a]!!L[%%a].%pickTemplate%!"
goto :eof
:init
rem initialize important global varibles
set "title=POC Ever-Generating Map Side Scroller"
set "tempfile=%temp%\tmpfont.file"
set "defaultMapID=001"
set "defaultFileExt=.txt"
set "numberOfTemplates=3"
rem Generate new font
if not exist "%tempfile%" (
echo.>"%tempfile%"
reg add "HKEY_CURREnt_USER\Console\%title%" /f >nul
for %%a in ("facename /t REG_SZ /d "terminal""
"fontfamily /t REG_DWoRD /d 0"
"fontSize /t REG_DWoRD /d 0xc"
"fontWeight /t REG_DWoRD /d 0"
) do ( set "param=%%a"& set "param=!param:~1!" & set "param=!param:~0,-1!"
reg add "HKEY_CURREnt_USER\Console\%title%" /f /v !param! >nul )
start /high /max "%title%" "%~f0" %* & exit
) else ( del /f /q "%tempfile%" )
rem clean up
for %%a in ("tempfile" "title" "defaultMapID" "param") do set "%%~a="
rem collect each template into it's own array of variables.
:: for example template001 has 10 lines
:: template 001 template002 template003
:: line 1 = ... line 1 = ... line 1 = ...
:: line 2 = ... line 2 = ... line 2 = ...
:: line 3 = ... line 3 = ... line 3 = ...
cd maps
for /l %%g in (1,1,!numberOfTemplates!) do (
set "maxY="
for /f "tokens=*" %%a in (template00%%g!defaultFileExt!) do (
set /a "maxY+=1"
set "L[!maxY!].%%g=%%~a"
)
)
cd..
rem $_ is 0, _$ = 30
:: for example:
:: set "String=There is some cool code here"
:: echo !String:~%$_%,%_$%!
:: %string:~0,30%
::CHANGE MODIFIER FOR GLOBAL SIZE
set "modifier=5"
set /a "DM=(modifier * 10) + 2"
set /a "$_=0", "_$=$_ + DM", "maxCam=_$ - 5"
for /l %%a in (1,1,!_$!) do set "out=!out!Û"
set /a "cols=maxCam + 9", "lines=maxY + 4"
rem each line is 10 characters long = 60 characters in length; double the display size.
for /l %%a in (1,1,!DM!) do call :generateImage
color f0
mode con: lines=!lines! cols=!cols!
goto :eofNOTE: IT IS IMPORTANT TO NAME THESE FILES AS LISTED, AND PLACED INTO A FOLDER CALLED "MAPS"(case insensitive) IN THE SAME DIRECTORY AS THE SCRIPT.
Spoiler (Click to View)
Template001.txt
Code
" (__) "
" (_____) "
" (_ __)"
" (_____ _____) "
" (__) "
" "
" ÛÛÛ "
" ÛÛ ÛÛÛÛÛ "
" Û Û "
" Û "Template002.txt
Code
" "
" (__) "
" (___)"
" (___) "
" "
" "
" "
" Û "
" Û Û "
" Û Û "Template003.txt
Code
" (_____) "
" (____ ) "
" (____) (___)"
" "
" "
" "
" ÛÛÛ "
"ÛÛÛÛ Û ÛÛÛÛÛÛÛÛÛ"
" Û Û "
" "

