Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- ::::::::::::::::::: DO NOT move OR rename OR modify THIS FILE. Filename: Game_Engine.bat
- ::: [ * Author: T3RRY * ] Creation Date - 16/12/2020 Developer version
- ::: Border and Sprite Macro definition package for Batch Arcade games
- ::: Purpose: Create a system to convert ASCII Art into sprites that can be moved and interacted with.
- ============================
- ::: COMPLETE archive with the latest updates:
- ::: Games_by_T3RRY: https://drive.google.com/file/d/1cAQLd-f9HN6SuWowBUETccKCZd2dVbWj/view?usp=sharing
- ::: See a DEMO using this engine:
- ::: https://www.youtube.com/watch?v=Wi3izdqbwcw
- ::: Leave a comment if you have any ideas or requests, Share a link if you want to show off your own games.
- ============================
- ::: Additional Accreditation
- ::: Getkey.Exe by Antonio {https://stackoverflow.com/users/778560/aacini}
- ::: * REQUIRED * for Extended key controls.
- ::: Getfontsize.Exe by Antonio {https://stackoverflow.com/users/778560/aacini}
- ::: From: https://stackoverflow.com/a/62087328/12343998
- ::: * REQUIRED * to accurately determine the consoles maximum Y;X values
- ::::::::::::::::::::::::::::
- ::: Sleep.bat by Dave Benham { https://stackoverflow.com/users/1012053/dbenham }
- ::: - Not required; allows for more precise sub second delays than other methods.
- =============================================================================
- ::: Recommended Resources:
- ::: Batch Macro's with Arguments Appended:
- ::: https://www.dostips.com/forum/viewtopic.php?f=3&t=2518
- ::: VT sequence Information:
- ::: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
- ::: 255 bit color chart [ for VT color sequences ]
- ::: https://www.rapidtables.com/web/color/RGB_Color.html
- =============================================================================
- ::: *** Important notes ***
- ::: Game_Engine.bat & Game_EngineDEBUG.bat Macro's:
- ::: - Enable definition; movement; rotation and collision / capture testing of ASCII sprites
- ::: Dev Toolkit - Refer to Game_EngineDEBUG.bat
- ::: - Contains advanced usage information ; performs error testing when Game_EngineDEBUG.bat defines Macros.
- ::: Defines Macro Resources required to run .Bat arcade Games_by_T3RRY
- ::: Game_Engine Macro's act as a whole system; and as such have dependencies on other macro's in the system
- ::: - Background.Border macro should ALWAYS be the first macro expanded; As it defines variables that
- ::: constrain the dimension of the playfield used by all other Sprite macros.
- ::: - Def.Sprite or Def.MultiCol.Sprite must be used to define sprites prior to Move.Sprite or Rotate.Sprite
- ::: being used
- =============================================================================
- :::::::::: Version 2.0 01/01/2021
- ::: Changes Jan 2021
- ::: *** Updated all .Sprite macros to support definition of sprite cells ***
- ::: using 255 bit Color codes. Ie: 38;2;200;25;100
- ::: Updated Def.Sprite and Def.Multicol.Sprite to define Obj.{l|m|u}{X|Y} variables
- ::: /* Changed Collide.Type Return Var to Obj.Collide.Type /*
- ::: - Object specific prefix allows more sophisticated testing of the collision types that have occured during a game "turn"
- ::: - enables more game design options like pushable sprites.
- ::: - Each sprite now has it's own array for captured / collided cells that can be tested
- :::: WHERE obj = SPRITEVARNAME
- ::: - Array Variables: index var: Array Name: Value:
- ::: Collision: Obj.Coll Obj.Collide.Type[Col][#=index] Collision Character
- ::: Capture : Obj.Capt Obj.Collide.Type[Cap][#=index] Capture Character
- ::: ** Obj.Coll and Obj.Capt return the total number of collisions and captures Obj=SPRITEVARNAME has had after a move.
- ::: - Added Getfontsize.exe to archive and calculation of true max console Dimensions.
- ::: - Expanded Error Testing and Debug output
- ::: - Cloned Game_Engine into Debug and Prodution versions
- ::: - Finished games can obtain a performance advantage by using the production version.
- :::::::::: Version 1.8 28/12/2020
- ::: Renamed to Game_Engine.bat
- ::: Version Changes 28/12/2020:
- ::: Added Play.Music and Stop.Music macro's to
- ::: Added Obj.Collide.Type return var to simplify testing of collision type that has occured within move.sprite macro
- ::: Added calculation of Sprite Mid{y;x} values to allow determination of sprite center
- ::: - Useful for calculating movement directions relevent to other sprites
- ::: - return vars: Obj.mx Obj.my [ Obj substituted with SPRITEVARNAME during Move.Sprite expansion ]
- ::: - Added SnakeSprite.bat to library to demonstrate how to apply sprite chase using these values
- :::::::::::::::::::::::::::::::
- ::: Version Changes 23/12/2020:
- ::: Added Rotate.Sprite Macro
- ::: Added Usage tests and output to Background.Border Def.Sprite Show.Sprite and Move.Sprite Macro's
- :::::::::::::::::::::::::::::::
- ::: Version Changes 19/12/2020:
- ::: Removed Response handling of collision from Move.Sprite macro
- ::: Upgraded move.sprite macro to accept arguments for Collision or Capture Characters
- ::: - return Vars [Collision is True: Valid=0] [Capture is True: Obj.capt=1]
- ::: - Implemented Title based level load indicator during sprite definition
- ::: - Improved modelling of handling game exit / End of level cleanup.
- ::: - Added 7th arg to Background.Border macro for flagging Border collision as Fatal T[0]/F[-1]
- :::::::::::::::
- rem /* Establish and verify required resources. Clearly separate script elements */
- rem /* Test Environment is suitable for definition of Macro's */
- If "!![" == "[" (Echo/Delayed expansion Must not be enabled prior to starting %~n0.bat & Pause & Exit /B 0)
- =============================================================================
- ::: CRITICAL RESOURCE DEFINITION AND VALIDATION
- =============================================================================
- CHCP 65001 > nul
- Set "MSG=Title ?"
- %MSG:?= Verifying Resources ...%
- rem /* use wmic output with find to test if system is windows 10. Exit with notice if not */
- wmic OS get OSArchitecture,caption | FIND "10" > nul || (ECHO/Windows 10 required for ascii escape codes & Exit /B)
- rem /* Define Escape character used for console virtual terminal sequences */
- rem - https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
- for /F "delims=#" %%a in ('"prompt #$E# & for %%a in (1) do rem"') do set "\E=%%a"
- rem /* Define Getkey path wit /n no wait parameter */
- For /F "Delims=" %%C in ('dir "%~dp0*GetKey.exe" /B /S') Do If not defined GetKey Set "GetKey="%%C" /n"
- rem /* Test getkey var is defined with valid exe path. Exit with notice if not. */
- Echo/%GetKey%|findstr.exe /LIC:"GetKey.exe" > nul || (Echo/GetKey.Exe not found in Directory. Game cannot be played without GetKey.exe &Pause &Exit /B 0)
- rem /* Ensure prefix used for Collision detection array unnassigned */
- (For /F "Tokens=1,2 Delims==" %%G in ('Set "}" 2^> Nul ')Do Set "%%~G=") 2> nul
- rem /* If TEMP path not found; Assign Current Directory as ~tmp file output folder */
- If not exist "%TEMP%" (Set "Save.Dir=%~dp0")Else Set "Save.Dir=%TEMP%\"
- rem /* Test write permission in the assigned directory. Exit with notice if no write permission */
- break >"%Save.Dir%%~n0_testpermission.com" || (
- Echo/Write permission required in %Save.Dir% to continue
- Pause
- Exit /B
- )
- Set Background="%Save.Dir%%~n0_background.~tmp"
- Set Foreground="%Save.Dir%%~n0_foreground.~tmp"
- DEL %Foreground% 2> Nul
- %= --------------------------------------------------------- =%
- ::: MACRO DEFINITIONS
- (Set LF=^
- %= Linefeed var. DO NOT MODIFY =%)
- (Set \n=^^^
- %= Macro newline var. DO NOT MODIFY =%)
- (Set COMMENT=rem - ^^^
- %= Macro Comment var. DO NOT MODIFY =%)
- =============================================================================
- ::: Screen Formatting and border definiton.
- rem /* Default Width for game control info panel */
- Set "CNTRL.Width=20"
- Set "}2;!CNTRL!=%\E%[2;!CNTRL!H%\E%[33mControls:"
- Set "}3;!CNTRL!=%\E%[3;!CNTRL!H ▲ - Up"
- Set "}4;!CNTRL!=%\E%[4;!CNTRL!H ◄ - Left"
- Set "}5;!CNTRL!=%\E%[5;!CNTRL!H ▼ - Down"
- Set "}6;!CNTRL!=%\E%[6;!CNTRL!H ► - Right"
- Set "}7;!CNTRL!=%\E%[7;!CNTRL!HSpace - Pause"
- Set "}8;!CNTRL!=%\E%[8;!CNTRL!HEscape - Quit"
- ::: Optional Macro providing Supplemental Information panel for game design debug purposes
- Set "Debug.Sprite=< nul Set /P "=%\E%[14;!CNTRL!H%\E%[38;2;0;60;70mObj.Coll - !Obj.Coll! %\E%[15;!CNTRL!HObj.Capt - !Obj.Capt! %\E%[16;!CNTRL!HType - !Obj.Collide.Type! %\E%[17;!CNTRL!HGrounded - !Obj.On.Surface! %\E%[18;!CNTRL!H{lmu}X - !Obj.lX!;!Obj.mX!;!Obj.uX! %\E%[19;!CNTRL!H{lmu}Y - !Obj.lY!;!Obj.mY!;!Obj.uY! %\E%[20;!CNTRL!Hwidth - !Obj.width! %\E%[0m""
- ::: BACKGROUND.BORDER macro. Define border color;dimensions;character;collision state.
- ::: Resizes console; padding right of the border for Control display
- ::: Defines Critical Variables needed for .sprite + other macro's; using the arguments supplied
- ::: - Get screen Dimensions
- For /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (
- Set "%%#">nul
- )
- ::: - Get scale Factor in effect. Registry value requires restart to update if scale has changed.
- For /F "Tokens=3 Delims= " %%A in ('REG QUERY "HKCU\Control Panel\Desktop\WindowMetrics" /V AppliedDPI') Do Set /A SF=%%A / 100 + 1
- ::: - Get Font Size
- (For /F "Delims=" %%S in ('dir GetFontSize.exe /B /S') Do (%%S)) 2> Nul
- Set /A "Font.H=%errorlevel% >> 16, Font.W=%errorlevel% & 0xFF"
- :::::::::: Calculate Max{Y;X} Constraints for Background.Border below
- Set /A "Max{X}= ( CurrentHorizontalResolution / ( Font.W * SF ) )"
- Set /A "Max{Y}= ( ( CurrentVerticalResolution / Font.H ) / SF ) - 4"
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- Set Background.Border=Set "Border=" ^& For %%n in (1 2)Do If %%n==2 ( %\n%
- For /F "Tokens=1-7 Delims={}" %%G in ("!Border!")Do If not "%%~M" == "" ( %\n%
- Set "Border.Color=%%~G" %\n%
- Set ".Xmin=%%~H" %\n%
- Set ".Xmax=%%~I" %\n%
- Set ".Ymin=%%~J" %\n%
- Set ".Ymax=%%~K" %\n%
- Set ".Char=%%~L" %\n%
- Set "?Border.Fatal=%%M" %\n%
- Set /A "CNTRL=!.Xmax!+5,cols=!.Xmax!+CNTRL.Width+5,lines=!.Ymax!+2" 2^> nul %\n%
- Set /A "Max{X}=Max{X}-(CNTRL.Width+5)" 2^> nul %\n%
- For %%w in (%%~H %%~I)Do for /L %%h in (%%~J,1,%%~K)Do ( %\n%
- Set "}%%h;%%w=%\E%[%%h;%%wH%\E%[%%~Gm!.Char!" %\n%
- For %%i in (%%~J %%~K)Do If %%h Equ %%i ( %\n%
- For /L %%W in (%%~H 1 %%~I)Do ( %\n%
- Set "}%%h;%%W=%\E%[%%h;%%WH%\E%[%%~Gm!.Char!" %\n%
- )))) %\n%
- mode !Cols!,!lines! %\n%
- )Else Set Border=
- =============================================================================
- Set "UPDATE.Background=Set /A ".End=!.Ymax! + 1" & ((For /F "Tokens=2* Delims==" %%G in ('Set "}"')Do (< nul Set /P "=%%~G%\E%[0m") & < nul Set /P "=%\E%[!.END!;1H%\E%[0m%\E%[?25l")) >%Background% & Type %Background%"
- =============================================================================
- rem /* Game macro Script timing */
- Set "Delay=If exist "%~dp0Components\Sleep.bat" ( Call "%~dp0Components\sleep.bat" # !time! )Else (For /L %%n in (1 1 10)Do ( Call :Delay 2> nul )))"
- =============================================================================
- ::: *** Key handling Macro's ***
- ::: Use Keytest_Game_Engine.Bat to Identify Ascii Integer values for the keys you wish to define
- Set "Def.Key.Usage=%%Def.Key%%"Ascii.key.Integer=String" "Ascii.key.Integer=String" "Ascii.key.Integers=String""
- Set "Def.Key=Set "input="&For %%n in (1 2)Do if %%n==2 (If "!input!" == "" (CLS & Mode 1000 & Echo/Echo/Error in Def.Key usage; Level !lvl!. Usage:!LF! !Def.Key.Usage! & Pause > nul & Endlocal & Exit )Else For %%I in (!input!)Do Set "k%%~I")Else Set input="
- ::: ?key# macro returns the string value of any key assigned using Def.Key when pressed in Variable: Key
- Set "?Key#=For %%n in (1 2)Do if %%n==2 (For %%E in (!Errorlevel!) Do If not "!k%%E!" == "" (Set "Key=!k%%E!" & (If /I "!Key!" == "space" ( Pause > nul )) & (For %%d in (left right up down)Do If /I "!Key!" == "%%d" (Set "Obj.Dir=%%d")))Else If not "%%E" == "0" ( If /I "mode" == "dev" (TITLE Key Errorcode - %%E & Pause > nul )))Else Set Obj.prv.Dir="
- Set "HASH=#"& Set "oHASH=Obj"
- =============================================================================
- ::: DEF.SPRITE : Converts Ascii art to objects [ a list ] with Defined Cordinates }Y;H=}Y;XHcharacter
- Set Def.Sprite=For %%n in (1 2)Do if %%n==2 ( %\n%
- Set "tMsg=Title Loading Level !lvl!" %\n%
- !tMsg! %\n%
- If Not "#" == "!HASH!" ( Set "{y}=#" ) %\n%
- Set /A "{y}+=1 + 0" %\n%
- For /F "Tokens=1,2,3 Delims={}" %%G in ("!Cells!")Do If not "%%~I" == "" ( %\n%
- Set "cell=%%I" %\n%
- Set "%%G.Color=%%~H" %\n%
- For /L %%i in (2 1 !.Xmin!)Do Set "cell= !cell!" %\n%
- For /L %%x in (0 1 !.Xmax!)Do If not "!cell:~%%x,1!" == "" ( %\n%
- If not "!cell:~%%x,1!" == " " ( %\n%
- Set "tMsg=!tMsg!." %\n%
- !tMsg! %\n%
- Set "tCell=!cell:~%%x,1!" %\n%
- If not "!%%G!" == "" ( %\n%
- For %%t in ("!tCell!")Do Set "t.%%G=!%%G:%%~t=!" %\n%
- If "!t.%%G!" == "!%%G!" Set "%%G.C=!%%G.C! "!tCell!"" %\n%
- ) Else (Set "Obj.C=!Obj.C! "!C.Tkn!"") %\n%
- FOR /F "Delims=" %%X in ('Set /A "{x}=%%x+!.Xmin!+1"')Do ( %\n%
- Set "}!{y}!;%%X=!{y}!;%%XH!cell:~%%x,1!" %\n%
- Set "%%G=!%%G!"!{y}!;%%XH!cell:~%%x,1!"," %\n%
- ))) %\n%
- Set /A "%%G.lX=!.Xmax!,%%G.uX=!.Xmin!,%%G.lY=!.Ymax!,%%G.uY=!.Ymin!" %\n%
- For %%S in (!%%G!)Do ( %\n%
- For /F "tokens=1,2 Delims=;H" %%3 in ("%%~S") Do (%\n%
- If %%3 GTR !%%G.uY! (Set "%%G.uY=%%3") %\n%
- If %%3 LSS !%%G.lY! (Set "%%G.lY=%%3") %\n%
- If %%4 GTR !%%G.uX! (Set "%%G.uX=%%4") %\n%
- If %%4 LSS !%%G.lX! (Set "%%G.lX=%%4") %\n%
- ) %\n%
- ) %\n%
- Set /A "%%G.mY=(!%%G.lY!+!%%G.uY!)/2,%%G.mX=(!%%G.lX!+!%%G.uX!)/2" %\n%
- Set /A "%%G.Width=(!%%G.uX!-!%%G.lX!) + 1" %\n%
- ) %\n%
- )Else Set Cells=
- =============================================================================
- ::: Def.Multicol.Sprite : Converts list of strings to sprite Ascii art with Defined Cordinates }Y;H=}Y;XHVTCOLORCODEcharacter
- ::: Stores last supplied VTCOLORCODE to SPRITEVARNAME.Color
- ::: Defines Cell as }Y;X=Y;XH%\E%[VTCOLORCODEmCHARACTER
- Set Def.Multicol.Sprite=For %%n in (1 2) Do if %%n==2 ( %\n%
- Set "Obj=" %\n%
- For %%G in (!Sprite.String!)Do ( %\n%
- Set "c.Tkn=%%~G" %\n%
- For /F "Tokens=1,2,3* Delims=;[H" %%1 in ("%%~G")Do ( %\n%
- Set "Obj.Color=%%~G" %\n%
- Set "c.Tkn=!Obj.Color:~-1!" %\n%
- Set "Obj.Color=!Obj.Color:*H=!" %\n%
- Set "Obj.Color=!Obj.Color:~0,-1!" %\n%
- If not "!Obj.C!" == "" ( %\n%
- For %%t in ("!c.Tkn!")Do Set "t.Obj=!Obj:%%~t=!" %\n%
- If "!t.Obj!" == "!Obj!" Set "Obj.C=!Obj.C! "!C.Tkn!"" %\n%
- ) Else (Set "Obj.C="!C.Tkn!"") %\n%
- Set "}%%1;%%2=%%1;%%2H%\E%[!Obj.Color!m!C.Tkn!" %\n%
- Set "Obj=!Obj!,"%%1;%%2H%\E%[!Obj.Color!m!C.Tkn!"" %\n%
- ) %\n%
- ) %\n%
- Set /A "Obj.lX=!.Xmax!,Obj.uX=!.Xmin!,Obj.lY=!.Ymax!,Obj.uY=!.Ymin!" %\n%
- For %%S in (!Obj!)Do ( %\n%
- For /F "tokens=1,2 Delims=;H" %%3 in ("%%~S") Do (%\n%
- If %%3 GTR !Obj.uY! (Set "Obj.uY=%%3") %\n%
- If %%3 LSS !Obj.lY! (Set "Obj.lY=%%3") %\n%
- If %%4 GTR !Obj.uX! (Set "Obj.uX=%%4") %\n%
- If %%4 LSS !Obj.lX! (Set "Obj.lX=%%4") %\n%
- ) %\n%
- ) %\n%
- Set /A "obj.mY=(!obj.lY!+!obj.uY!)/2,obj.mX=(!obj.lX!+!obj.uX!)/2" %\n%
- Set /A "Obj.Width=!Obj.uX!-!Obj.lX!+1" %\n%
- )Else Set Sprite.String=
- =============================================================================
- ::: SHOW : Iterates over the list value of a substituted sprite variable and outputs value.
- =============================================================================
- rem /* USAGE: %Show:obj=SpriteVARNAME% */ [ Displays spritenames cells ]
- Set "Show=If /I "!oHASH!" == "Obj" (<nul Set /P "=%\E%[!.End!;1HError in level !lvl!. Unknown Sprite not displayed^^^!.!LF! Usage: %%Show:!oHASH!=SpriteVARNAME%%")Else For %%g in (!obj!)Do ((Set "oStr=%%~g") & < nul Set /P "=%\E%[!Obj.Color!m%\E%[!oStr!%\E%[0m")"
- rem /* Variables used to convert Direction to Vector in Move.Sprite Macro*/
- =============================================================================
- rem /* Inverse Player movements for lazy AI control */
- Set ".Left=Right"&Set ".Right=Left"&Set ".Up=Down"&Set ".Down=Up"
- rem /* Clockwise rotation for use with rotate.sprite macro */
- Set "rLeft=up"&Set "rRight=down"&Set "rUp=right"&Set "rDown=left"
- Set "Left={x}{-}"& Set "Right={x}{+}"& Set "Up={y}{-}"& Set "Down={y}{+}"
- Set "{x}{-}=Left"& Set "{x}{+}=Right"& Set "{y}{-}=Up"& Set "{y}{+}=Down"
- Set Move.Sprite=For %%n in (1 2) Do if %%n==2 ( %\n%
- Set "Sub=" %\n%
- (For /F "Tokens=1 Delims==" %%l in ('Set Obj.Collide.Type')Do Set "%%l=") 2^> nul %\n%
- Set /A "valid=1,Obj.capt=0,Obj.Coll=0" %\n%
- For /F "Tokens=1,2,3,4 Delims={}" %%G in ("!Move.Args!")Do ( %\n%
- Set "axis=%%~G" %\n%
- Set "vector=%%~H" %\n%
- Set "nDir=!{%%~G}{%%~H}!" %\n%
- If not "%%~I" == "" (Set "Collide=%%I")Else ( Set "Collide=" ) %\n%
- If not "%%~J" == "" (Set "Flag=%%J")Else ( Set "Flag=" ) %\n%
- ) %\n%
- If /I "!axis!" == "X" ( %\n%
- For %%g in (!obj!) Do ( %\n%
- For /F "Tokens=1,2,3 Delims=;H" %%i in ("%%~g") Do ( %\n%
- Set /A "cx=%%j!vector!1,oy=%%i,ox=%%j" %\n%
- Set "cTkn=%%~g" %\n%
- Set "cTkn=!cTkn:*H=!" %\n%
- For /F "Delims=" %%o in ("!cx!") Do ( %\n%
- Set "q.cell=" %\n%
- Set "q.cell=!}%%i;%%o!" %\n%
- If not "!q.Cell!" == "" (Set "q.Cell=!q.cell:~-1!") %\n%
- For /F "Delims=" %%K in ("!q.Cell!") Do ( %\n%
- If not "!Collide:%%K=!" == "!Collide!" ( %\n%
- Set "Valid=0" %\n%
- Set /A "Obj.Coll+=1 + 0" %\n%
- Set "Obj.Collide.Type[Col][!Obj.Coll!]=%%K" %\n%
- Set "Obj.Collide.Type=%%~K" %\n%
- ) %\n%
- If "%%K" == "!.Char!" ( %\n%
- Set "Valid=!?Border.Fatal!" %\n%
- Set /A "Obj.Coll+=1 + 0" %\n%
- Set "Obj.Collide.Type[Col][!Obj.Coll!]=%%K" %\n%
- Set "Obj.Collide.Type=%%K" %\n%
- ) %\n%
- If not "!Flag:%%K=!" == "!Flag!" ( %\n%
- If "!Valid!" == "1" ( %\n%
- Set /A "Obj.Capt+=1 + 0" %\n%
- Set "Obj.Collide.Type[Cap][!Obj.Capt!]=%%K" %\n%
- Set "Obj.Collide.Type=%%K" %\n%
- )Else ( %\n%
- Set "Obj.Capt=0" %\n%
- (For /F "tokens=1,2 Delims==" %%1 in ('Set Obj.Collide.Type[Cap]')Do Set "%%1=") 2^> nul %\n%
- ) %\n%
- ) %\n%
- ) %\n%
- If "!valid!" == "1" (Set "Sub=!Sub!"%%i;%%oH!cTKN!",") %\n%
- )))) ELSE ( %\n%
- For %%g in (!obj!) Do ( %\n%
- For /F "Tokens=1,2,3 Delims=;H" %%i in ("%%~g") Do ( %\n%
- Set /A "cy=%%i!vector!1,oy=%%i,ox=%%j" %\n%
- Set "cTkn=%%~g" %\n%
- Set "cTkn=!cTkn:*H=!" %\n%
- For /F "Delims=" %%o in ("!cy!") Do ( %\n%
- Set "q.cell=" %\n%
- Set "q.cell=!}%%o;%%j!" %\n%
- If not "!q.Cell!" == "" (Set "q.Cell=!q.cell:~-1!") %\n%
- For /F "Delims=" %%K in ("!q.Cell!") Do ( %\n%
- If not "!Collide:%%K=!" == "!Collide!" ( %\n%
- Set "Valid=0" %\n%
- Set /A "Obj.Coll+=1 + 0" %\n%
- Set "Obj.Collide.Type[Col][!Obj.Coll!]=%%K" %\n%
- Set "Obj.Collide.Type=%%~K" %\n%
- ) %\n%
- If "%%K" == "!.Char!" ( %\n%
- Set "Valid=!?Border.Fatal!" %\n%
- Set /A "Obj.Coll+=1 + 0" %\n%
- Set "Obj.Collide.Type[Col][!Obj.Coll!]=%%K" %\n%
- Set "Obj.Collide.Type=%%K" %\n%
- ) %\n%
- If not "!Flag:%%K=!" == "!Flag!" ( %\n%
- If "!Valid!" == "1" ( %\n%
- Set /A "Obj.Capt+=1 + 0" %\n%
- Set "Obj.Collide.Type[Cap][!Obj.Capt!]=%%K" %\n%
- Set "Obj.Collide.Type=%%K" %\n%
- )Else ( %\n%
- Set "Obj.Capt=0" %\n%
- (For /F "tokens=1,2 Delims==" %%1 in ('Set Obj.Collide.Type[Cap]')Do Set "%%1=") 2^> nul %\n%
- ) %\n%
- ) %\n%
- ) %\n%
- If "!valid!" == "1" (Set "Sub=!Sub!"%%o;%%jH!cTKN!",") %\n%
- ))))%\n%
- If "!valid!" == "1" (%\n%
- Set /A "Obj.lX=!.Xmax!,Obj.uX=!.Xmin!,Obj.lY=!.Ymax!,Obj.uY=!.Ymin!" %\n%
- (For %%Q in (!obj!)Do ( %\n%
- For /F "tokens=1,2 Delims=;H" %%1 in ("%%~Q") Do (%\n%
- Set "}%%~1;%%~2=" %\n%
- Echo/%\E%[%%1;%%2H %\n%
- )))^>%Foreground% %\n%
- Set "Obj.on.surface=0" %\n%
- Set "Obj.Surface=" %\n%
- Set "obj.on.fatal=" %\n%
- Set "Obj.Base.I=0" %\n%
- (For %%S in (!Sub!)Do ( %\n%
- For /F "tokens=1,2,3* Delims=;H" %%3 in ("%%~S") Do (%\n%
- If %%3 GTR !Obj.uY! (Set "Obj.uY=%%3") %\n%
- If %%3 LSS !Obj.lY! (Set "Obj.lY=%%3") %\n%
- If %%4 GTR !Obj.uX! (Set "Obj.uX=%%4") %\n%
- If %%4 LSS !Obj.lX! (Set "Obj.lX=%%4") %\n%
- Set "cTKN=%%~S" %\n%
- Set "cTKN=!cTKN:*H=!" %\n%
- Set "}%%~3;%%~4=%%~3;%%~4H!cTKN!" %\n%
- Echo/%\E%[%%~3;%%~4H%\E%[!Obj.Color!m!cTKN!%\E%[0m%\n%
- ))) ^>^>%Foreground% %\n%
- Set /A Below.Sprite=!Obj.uY!+1 %\n%
- For %%k in (!Obj.uY!)Do For /L %%a in (!Obj.lX! 1 !Obj.uX!)Do If not "!}%%k;%%a!" == "" ( %\n%
- For %%b in (!Below.Sprite!)Do For %%c in (!.Char! !Collide! !Flag!)Do ( %\n%
- If /I "!}%%b;%%a:~-1!" == "%%~c" ( %\n%
- Set "Obj.on.surface=1" %\n%
- %COMMENT:{i}= All cells sprite rests on returned in list var below. Use list to differentiate surface types - IE ground ; lava ; water \n%
- Set "Obj.surface=!Obj.surface!"!}%%b;%%a!"," %\n%
- %!!%
- If "!fatal.%%c!" == "1" (Set /A "obj.on.fatal+=1 + 0") %\n%
- ) %\n%
- Set /A "Obj.Base.I+=1" %\n%
- ) %\n%
- ) %\n%
- If "!Obj.on.Fatal!" == "!Obj.Base.I!" (Set "obj.State=dead") %\n%
- TYPE %Foreground% %\n%
- If not "!Obj.Collide.Type!" == "!.Char!" Set "obj=!Sub!" %\n%
- Set /A "obj.mY=(!obj.lY!+!obj.uY!)/2,obj.mX=(!obj.lX!+!obj.uX!)/2" %\n%
- Set "Obj.Dir=!nDir!" %\n%
- ) %\n%
- )Else Set Move.Args=
- =============================================================================
- ::: Rotate.Sprite Macro - rotates a sprite cells and direction clockwise
- Set Rotate.Sprite=For %%n in (1 2) Do if %%n==2 ( %\n%
- (For %%s in ("cTkn" "ny" "nx" "oy" "ox" "iy" "ix" "Obj.Collide.Type") Do For /F "Tokens=1,2 Delims==" %%G in ('Set "%%~s"')Do Set "%%~G=") 2^> nul %\n%
- Set "Sub=" %\n%
- Set /A "midX=500,midY=500,{I}=0,rValid=1,Obj.Coll=0,Obj.capt=0" %\n%
- For %%g in (!obj!) Do If not "%%~g" == "" ( %\n%
- Set /A "{I}+=1 + 0" %\n%
- For /F "Tokens=1,2,3* Delims=;H" %%I in ("%%~g") Do ( %\n%
- Set /A "iy!{I}!=%%~I" %\n%
- Set /A "ix!{I}!=%%~J" %\n%
- Set "cTKN!{I}!=%%~g" %\n%
- For %%z in (!{I}!)Do Set "cTKN!{I}!=!cTKN%%z:*H=!" %\n%
- ) %\n%
- ) %\n%
- For /L %%i in (1 1 !{I}!) do For %%A in ("!iy%%i!;!ix%%i!")Do ( %\n%
- For /F "Tokens=1,2 Delims=;" %%X in ("%%~A") Do ( %\n%
- Set /A "oY=%%~X" %\n%
- Set /A "oX=%%~Y" %\n%
- ) %\n%
- If !oY! LSS !midY! Set /A "midY=!oY!" %\n%
- If !oX! LSS !midX! Set /A "midX=!oX!" %\n%
- ) %\n%
- Set "pixel=0" %\n%
- For /L %%i in (1 1 !{I}!) do For %%B in ("!iy%%i!;!ix%%i!")Do ( %\n%
- Set /A "pixel+=1" %\n%
- For /F "Tokens=1,2 Delims=;" %%r in ("%%~B") Do ( %\n%
- Set /A "ny!pixel!=(%%~s-!midX!)+!midY!,nx!pixel!=(%%~r-!midY!)+!midX!" %\n%
- ) %\n%
- ) %\n%
- Set "pixel=0" %\n%
- Set /A "lmidX=500,umidX=0" %\n%
- For /L %%i in (1 1 !{I}!) do For %%C in (!nx%%i!) Do ( %\n%
- If %%C LSS !lmidX! (Set /A "lmidX=%%C") %\n%
- If %%C GTR !umidX! (Set /A "umidX=%%C") %\n%
- ) %\n%
- Set /A "Obj.Width=!umidX!-!lmidX!" %\n%
- For /L %%i in (1 2 19)Do If !Obj.Width! EQU %%i Set "Centre=0" %\n%
- For /L %%i in (0 2 20)Do If !Obj.Width! EQU %%i Set "Centre=1" %\n%
- Set /A "Obj.Width+=1" %\n%
- if !umidX!==!lmidX! Set "Centre=0" %\n%
- Set /A "Mid.X=( !lmidX! + !umidX! ) / 2" %\n%
- For /L %%i in (1 1 !{I}!) do For %%X in (!nx%%i!) Do ( %\n%
- Set /A "pixel=!pixel! + 1" %\n%
- Set /A "nx!pixel!=%%X + !centre!" %\n%
- IF %%X LSS !Mid.X! (Set /A "nx!pixel!= %%X + ((!Mid.X!-%%X) * 2) + !centre!") %\n%
- IF %%X GTR !Mid.X! (Set /A "nx!pixel!= %%X - ((%%X-!Mid.X!) * 2) + !centre!") %\n%
- ) %\n%
- For /F "Tokens=1,2,3,4 Delims={}" %%o in ("!rVector!") Do ( %\n%
- Set "cDir=%%o" %\n%
- Set "Flag=%%q" %\n%
- ) %\n%
- For /L %%i in (1 1 !{I}!)Do ( %\n%
- for %%c in ("!ny%%i!;!nx%%i!")Do If not "!}%%~c!" == "" ( %\n%
- For /F "Tokens=2 Delims={}" %%m in ("!rVector!")Do Set "Collide=%%m" %\n%
- For %%v in (!Collide!) Do If not "!}%%~c!" == "" ( %\n%
- Set "KO=!}%%~c:%%~v=!" %\n%
- If Not "!}%%~c!" == "!KO!" (%\n%
- Set "rValid=0" %\n%
- Set "Obj.Collide.Type=%%~v" %\n%
- Set /A "Obj.Coll+=1" %\n%
- Set "Obj.Collide.Type[Col][!Obj.Coll!]=%%~v" %\n%
- ) %\n%
- ) %\n%
- ) %\n%
- ) %\n%
- If "!rValid!" == "1" ( %\n%
- Set "Obj.Dir=!cDir!"%\n%
- For /L %%i in (1 1 !{I}!) do ( %\n%
- Set "Sub=!Sub!"!ny%%i!;!nx%%i!H!cTkn%%i!"," %\n%
- For %%P in (!Flag!)Do for %%v in ("!ny%%i!;!nx%%i!")Do If Not "!}%%~v!" == "" ( %\n%
- Set "flag.C=!}%%~v:%%~P=!" %\n%
- Set "flag.Cell=!}%%~v!" %\n%
- If Not "!flag.Cell!" == "!flag.C!" ( %\n%
- Set /A "Obj.capt+=1 + 0" %\n%
- Set "Obj.Collide.Type=!cTkn%%i:~-1!" %\n%
- Set "Obj.Collide.Type[Cap][!Obj.capt!]=!cTkn%%i:~-1!" %\n%
- ) %\n%
- ) %\n%
- ) %\n%
- (For %%Q in (!obj!)Do ( %\n%
- For /F "tokens=1,2 Delims=;H" %%1 in ("%%~Q") Do (%\n%
- Set "}%%1;%%2=" %\n%
- Echo/%\E%[%%1;%%2H %\n%
- )))^>%Foreground% %\n%
- Set "Obj.on.surface=0" %\n%
- Set "Obj.Surface=" %\n%
- Set "obj.on.fatal=" %\n%
- Set "obj.Base.I=" %\n%
- (For %%S in (!Sub!)Do ( %\n%
- For /F "tokens=1,2,3 Delims=;H" %%3 in ("%%~S") Do (%\n%
- Set "cTKN=%%~S" %\n%
- Set "cTKN=!cTKN:*H=!" %\n%
- Set "}%%3;%%4=%%3%!!%%4H!cTKN!" %\n%
- Echo/%\E%[%%3;%%4H%\E%[!Obj.Color!m!cTKN!%\E%[0m%\n%
- ))) ^>^>%Foreground% %\n%
- TYPE %Foreground% %\n%
- Set /A Below.Sprite=!Obj.uY!+1 %\n%
- For %%k in (!Obj.uY!)Do For /L %%a in (!Obj.lX! 1 !Obj.uX!)Do If not "!}%%k;%%a!" == "" ( %\n%
- For %%b in (!Below.Sprite!)Do For %%c in (!.Char! !Collide! !Flag!)Do ( %\n%
- If /I "!}%%b;%%a:~-1!" == "%%~c" ( %\n%
- Set "Obj.on.surface=1" %\n%
- Set "Obj.surface=!Obj.surface!"!}%%b;%%a!"," %\n%
- If "!fatal.%%c!" == "1" (Set /A "obj.on.fatal+=1 + 0") %\n%
- ) %\n%
- Set /A "Obj.Base.I+=1" %\n%
- ) %\n%
- ) %\n%
- If "!Obj.on.Fatal!" == "!Obj.Base.I!" (Set "obj.State=dead") %\n%
- Set "obj=!Sub!" %\n%
- Set "Sub=" %\n%
- ) %\n%
- )Else Set rVector=
- ========================================================================================================
- ::: Macro's for using the Music system included in the Games_By_T3RRY archive
- Set "Play.Music=If Exist "%~dp0Components\PlayMusic.bat" For %%n in (1 2)Do if %%n==2 (For /F "Tokens=1,2,3 Delims={}" %%G in ("!Music.Args!")Do (Call "%~dp0Components\PlayMusic.bat" "%%~G" %%H %%I ))else Set Music.Args="
- Set "Stop.Music=If Exist "%~dp0Components\StopMusic.bat" (Call "%~dp0Components\StopMusic.Bat" running 2> nul )"
- Set "Monitor.Game=Call "%~dp0Components\Gamemonitor.bat" start 2> nul"
- Exit /B 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement