Hello, I have an idea for a "game" that I am programming, which I have already posted 1-2 questions for here already. Here's another question.
So the game has a field where you can walk around using WASD. I want the player (#) to have a 3 "block" radius of "light" that is radiating from the player.
Well what should that look like in the end? The 3 "block"-radius is in a brighter color than the rest of the gamefield. The unlit part should be darkgray, and the lit part should be brightgray. The player shouldn't be lit. With "block" I mean one char like "▒" or █. The "#"'s at the top and bottom are not part of the field.
Hard to explain, here are some screenshots:
https://imgur.com/a/EYDFM
The red dots represent the radius, the yellow part roughly shows the part that should be light gray.
The code:
http://pastebin.com/raw/4HbEGA3L
Code of the colors I am talking about:
http://pastebin.com/raw/pHdtCGP8
I would greatly appreciate if you can help me
If you have any questions, feel free to ask. Thanks.
Problem with a game
Moderator: DosItHelp
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Problem with a game
What the end result looks like is up to you. I'm not entirely sure what you're asking; it seems like you already know what you want to do. Are you looking for the code for how to implement it?
Re: Problem with a game
ShadowThief wrote:What the end result looks like is up to you. I'm not entirely sure what you're asking; it seems like you already know what you want to do. Are you looking for the code for how to implement it?
Exactly! I do not know how to program it :/
-
- Posts: 240
- Joined: 04 Mar 2014 11:14
- Location: germany
Re: Problem with a game
You test this
Write for the axis x;y and exclude.
Phil
Write for the axis x;y and exclude.
Code: Select all
@echo off
@setlocal EnableDelayedExpansion
@mode con cols=58 lines=18
@color f0
@for %%i in (choice.exe) do @(
for /f "delims==-" %%i in ('2^>nul set') do set "%%i="
set Path=%%~dp$PATH:i
)
@set prompt=$G$S
@for /L %%i in (58,1,503) do @set "u%%i=±"
@for /L %%i in (1,1,57) do @set "u%%i=Û"
@for /L %%i in (505,1,559) do @set "u%%i=Û"
@for /L %%i in (113,56,505) do @set "u%%i=Û"
@for /L %%i in (112,56,560) do @set "u%%i=Û"
::set first position of the player
@set "u115=#"
@set /a position=115
::set the movements
:: D S A W
set /a "m_0=mov[4]=1", "m_2=mov[3]=56", "m_4=mov[2]=-1," "m_6=mov[1]= -56",^
"m_1=m_0+m_2", "m_3=m_4+m_2","m_5=m_4+m_6","m_7=m_0+m_6",^
"s_0=2*m_0", "s_3=2*m_2", "s_6=2*m_4" ,"s_9=2*m_6",^
"s_1=s_0+m_2","s_2=m_0+s_3","s_4=m_4+s_3","s_5=s_6+m_2",^
"s_7=s_6+m_6","s_8=m_4+s_9","s_10=m_0+s_9","s_11=s_0+m_7",^
"r_3=s_0+s_3","r_9=s_6+s_3","r_15=s_6+s_9","r_21=s_0+s_9"
: "r_0=3*m_0", "r_6=3*m_2", "r_12=3*m_4", "r_18=3*m_6",^
: "r_1=r_0+m_2","r_2=r_0+s_3","r_4=s_0+r_6","r5=m_0+r_6",^
: "r_7=m_4+r_6","r_8=s_6+r_6","r_10=r_12+s_3","r_11=r_12+m_2",^
: "r_13=r_12+m_6","r_14=r_12+s_9","r_16=s_6+r_18","r_17=m4+r_18"^
: ,"r_19=m_0+r_18","r_20=s_0+r_18","r_22=r_0+s_9",r_23=r_0+m_6"
set "m_="
for /f "tokens=1,2 delims==" %%i in ('set m_') do set m_=!m_! "%%j"&set "%%i="
for /f "tokens=1,2 delims==" %%i in ('set s_ ^&set r_') do set s_=!s_! "%%j"&set "%%i="
set ^"LF=^
^" Above empty line is required - do not remove
:: define CR as a Carriage Return character
@for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
:@:main
:@call :screen
:@goto :main
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@:screen
@set "SCR_="
::for /l %%i in (0 1 9) do @if NOT defined SCR_ if %time:~-2% neq !time:~-2!
set "SCR_=!time!"
@if not defined SCR_ (exit /b) else @title %position% &cls &echo !SCR_!!LF!##########################################################^
#%u1%%u2%%u3%%u4%%u5%%u6%%u7%%u8%%u9%%u10%%u11%%u12%%u13%%u14%%u15%%u16%%u17%%u18%%u19%%u20%%u21%%u22%%u23%%u24%%u25%%u26%%u27%%u28%%u29%%u30%%u31%%u32%%u33%%u34%%u35%%u36%%u37%%u38%%u39%%u40%%u41%%u42%%u43%%u44%%u45%%u46%%u47%%u48%%u49%%u50%%u51%%u52%%u53%%u54%%u55%%u56%^
##%u57%%u58%%u59%%u60%%u61%%u62%%u63%%u64%%u65%%u66%%u67%%u68%%u69%%u70%%u71%%u72%%u73%%u74%%u75%%u76%%u77%%u78%%u79%%u80%%u81%%u82%%u83%%u84%%u85%%u86%%u87%%u88%%u89%%u90%%u91%%u92%%u93%%u94%%u95%%u96%%u97%%u98%%u99%%u100%%u101%%u102%%u103%%u104%%u105%%u106%%u107%%u108%%u109%%u110%%u111%%u112%^
##%u113%%u114%%u115%%u116%%u117%%u118%%u119%%u120%%u121%%u122%%u123%%u124%%u125%%u126%%u127%%u128%%u129%%u130%%u131%%u132%%u133%%u134%%u135%%u136%%u137%%u138%%u139%%u140%%u141%%u142%%u143%%u144%%u145%%u146%%u147%%u148%%u149%%u150%%u151%%u152%%u153%%u154%%u155%%u156%%u157%%u158%%u159%%u160%%u161%%u162%%u163%%u164%%u165%%u166%%u167%%u168%^
##%u169%%u170%%u171%%u172%%u173%%u174%%u175%%u176%%u177%%u178%%u179%%u180%%u181%%u182%%u183%%u184%%u185%%u186%%u187%%u188%%u189%%u190%%u191%%u192%%u193%%u194%%u195%%u196%%u197%%u198%%u199%%u200%%u201%%u202%%u203%%u204%%u205%%u206%%u207%%u208%%u209%%u210%%u211%%u212%%u213%%u214%%u215%%u216%%u217%%u218%%u219%%u220%%u221%%u222%%u223%%u224%^
##%u225%%u226%%u227%%u228%%u229%%u230%%u231%%u232%%u233%%u234%%u235%%u236%%u237%%u238%%u239%%u240%%u241%%u242%%u243%%u244%%u245%%u246%%u247%%u248%%u249%%u250%%u251%%u252%%u253%%u254%%u255%%u256%%u257%%u258%%u259%%u260%%u261%%u262%%u263%%u264%%u265%%u266%%u267%%u268%%u269%%u270%%u271%%u272%%u273%%u274%%u275%%u276%%u277%%u278%%u279%%u280%^
##%u281%%u282%%u283%%u284%%u285%%u286%%u287%%u288%%u289%%u290%%u291%%u292%%u293%%u294%%u295%%u296%%u297%%u298%%u299%%u300%%u301%%u302%%u303%%u304%%u305%%u306%%u307%%u308%%u309%%u310%%u311%%u312%%u313%%u314%%u315%%u316%%u317%%u318%%u319%%u320%%u321%%u322%%u323%%u324%%u325%%u326%%u327%%u328%%u329%%u330%%u331%%u332%%u333%%u334%%u335%%u336%^
##%u337%%u338%%u339%%u340%%u341%%u342%%u343%%u344%%u345%%u346%%u347%%u348%%u349%%u350%%u351%%u352%%u353%%u354%%u355%%u356%%u357%%u358%%u359%%u360%%u361%%u362%%u363%%u364%%u365%%u366%%u367%%u368%%u369%%u370%%u371%%u372%%u373%%u374%%u375%%u376%%u377%%u378%%u379%%u380%%u381%%u382%%u383%%u384%%u385%%u386%%u387%%u388%%u389%%u390%%u391%%u392%^
##%u393%%u394%%u395%%u396%%u397%%u398%%u399%%u400%%u401%%u402%%u403%%u404%%u405%%u406%%u407%%u408%%u409%%u410%%u411%%u412%%u413%%u414%%u415%%u416%%u417%%u418%%u419%%u420%%u421%%u422%%u423%%u424%%u425%%u426%%u427%%u428%%u429%%u430%%u431%%u432%%u433%%u434%%u435%%u436%%u437%%u438%%u439%%u440%%u441%%u442%%u443%%u444%%u445%%u446%%u447%%u448%^
##%u449%%u450%%u451%%u452%%u453%%u454%%u455%%u456%%u457%%u458%%u459%%u460%%u461%%u462%%u463%%u464%%u465%%u466%%u467%%u468%%u469%%u470%%u471%%u472%%u473%%u474%%u475%%u476%%u477%%u478%%u479%%u480%%u481%%u482%%u483%%u484%%u485%%u486%%u487%%u488%%u489%%u490%%u491%%u492%%u493%%u494%%u495%%u496%%u497%%u498%%u499%%u500%%u501%%u502%%u503%%u504%^
##%u505%%u506%%u507%%u508%%u509%%u510%%u511%%u512%%u513%%u514%%u515%%u516%%u517%%u518%%u519%%u520%%u521%%u522%%u523%%u524%%u525%%u526%%u527%%u528%%u529%%u530%%u531%%u532%%u533%%u534%%u535%%u536%%u537%%u538%%u539%%u540%%u541%%u542%%u543%%u544%%u545%%u546%%u547%%u548%%u549%%u550%%u551%%u552%%u553%%u554%%u555%%u556%%u557%%u558%%u559%%u560%^
###########################################################
:auto
set /A "x=%random%,x=X%%4+1"
set "newPos=!mov[%x%]!"
set /a "newPos+=Position"
if !u1! == !u%newPos%! goto :auto
set "u%position%=±"
set "position=%newPos%"
set "u!position!=#"
for %%i in (%m_%) do for /f "delims=" %%K in ('set /a "K=Position+%%i"') do if !u%%K! neq Û set "u%%K=."
for %%i in (%s_%) do for /f "delims=" %%K in ('set /a "K=Position+%%i"') do if !u%%K! neq ± if !u%%K! neq Û @set "u%%K=±"
goto :screen
:@exit /b
Phil
Re: Problem with a game
pieh-ejdsch wrote:You test this
Write for the axis x;y and exclude.Code: Select all
@echo off
@setlocal EnableDelayedExpansion
@mode con cols=58 lines=18
@color f0
@for %%i in (choice.exe) do @(
for /f "delims==-" %%i in ('2^>nul set') do set "%%i="
set Path=%%~dp$PATH:i
)
@set prompt=$G$S
@for /L %%i in (58,1,503) do @set "u%%i=±"
@for /L %%i in (1,1,57) do @set "u%%i=Û"
@for /L %%i in (505,1,559) do @set "u%%i=Û"
@for /L %%i in (113,56,505) do @set "u%%i=Û"
@for /L %%i in (112,56,560) do @set "u%%i=Û"
::set first position of the player
@set "u115=#"
@set /a position=115
::set the movements
:: D S A W
set /a "m_0=mov[4]=1", "m_2=mov[3]=56", "m_4=mov[2]=-1," "m_6=mov[1]= -56",^
"m_1=m_0+m_2", "m_3=m_4+m_2","m_5=m_4+m_6","m_7=m_0+m_6",^
"s_0=2*m_0", "s_3=2*m_2", "s_6=2*m_4" ,"s_9=2*m_6",^
"s_1=s_0+m_2","s_2=m_0+s_3","s_4=m_4+s_3","s_5=s_6+m_2",^
"s_7=s_6+m_6","s_8=m_4+s_9","s_10=m_0+s_9","s_11=s_0+m_7",^
"r_3=s_0+s_3","r_9=s_6+s_3","r_15=s_6+s_9","r_21=s_0+s_9"
: "r_0=3*m_0", "r_6=3*m_2", "r_12=3*m_4", "r_18=3*m_6",^
: "r_1=r_0+m_2","r_2=r_0+s_3","r_4=s_0+r_6","r5=m_0+r_6",^
: "r_7=m_4+r_6","r_8=s_6+r_6","r_10=r_12+s_3","r_11=r_12+m_2",^
: "r_13=r_12+m_6","r_14=r_12+s_9","r_16=s_6+r_18","r_17=m4+r_18"^
: ,"r_19=m_0+r_18","r_20=s_0+r_18","r_22=r_0+s_9",r_23=r_0+m_6"
set "m_="
for /f "tokens=1,2 delims==" %%i in ('set m_') do set m_=!m_! "%%j"&set "%%i="
for /f "tokens=1,2 delims==" %%i in ('set s_ ^&set r_') do set s_=!s_! "%%j"&set "%%i="
set ^"LF=^
^" Above empty line is required - do not remove
:: define CR as a Carriage Return character
@for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"
:@:main
:@call :screen
:@goto :main
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@:screen
@set "SCR_="
::for /l %%i in (0 1 9) do @if NOT defined SCR_ if %time:~-2% neq !time:~-2!
set "SCR_=!time!"
@if not defined SCR_ (exit /b) else @title %position% &cls &echo !SCR_!!LF!##########################################################^
#%u1%%u2%%u3%%u4%%u5%%u6%%u7%%u8%%u9%%u10%%u11%%u12%%u13%%u14%%u15%%u16%%u17%%u18%%u19%%u20%%u21%%u22%%u23%%u24%%u25%%u26%%u27%%u28%%u29%%u30%%u31%%u32%%u33%%u34%%u35%%u36%%u37%%u38%%u39%%u40%%u41%%u42%%u43%%u44%%u45%%u46%%u47%%u48%%u49%%u50%%u51%%u52%%u53%%u54%%u55%%u56%^
##%u57%%u58%%u59%%u60%%u61%%u62%%u63%%u64%%u65%%u66%%u67%%u68%%u69%%u70%%u71%%u72%%u73%%u74%%u75%%u76%%u77%%u78%%u79%%u80%%u81%%u82%%u83%%u84%%u85%%u86%%u87%%u88%%u89%%u90%%u91%%u92%%u93%%u94%%u95%%u96%%u97%%u98%%u99%%u100%%u101%%u102%%u103%%u104%%u105%%u106%%u107%%u108%%u109%%u110%%u111%%u112%^
##%u113%%u114%%u115%%u116%%u117%%u118%%u119%%u120%%u121%%u122%%u123%%u124%%u125%%u126%%u127%%u128%%u129%%u130%%u131%%u132%%u133%%u134%%u135%%u136%%u137%%u138%%u139%%u140%%u141%%u142%%u143%%u144%%u145%%u146%%u147%%u148%%u149%%u150%%u151%%u152%%u153%%u154%%u155%%u156%%u157%%u158%%u159%%u160%%u161%%u162%%u163%%u164%%u165%%u166%%u167%%u168%^
##%u169%%u170%%u171%%u172%%u173%%u174%%u175%%u176%%u177%%u178%%u179%%u180%%u181%%u182%%u183%%u184%%u185%%u186%%u187%%u188%%u189%%u190%%u191%%u192%%u193%%u194%%u195%%u196%%u197%%u198%%u199%%u200%%u201%%u202%%u203%%u204%%u205%%u206%%u207%%u208%%u209%%u210%%u211%%u212%%u213%%u214%%u215%%u216%%u217%%u218%%u219%%u220%%u221%%u222%%u223%%u224%^
##%u225%%u226%%u227%%u228%%u229%%u230%%u231%%u232%%u233%%u234%%u235%%u236%%u237%%u238%%u239%%u240%%u241%%u242%%u243%%u244%%u245%%u246%%u247%%u248%%u249%%u250%%u251%%u252%%u253%%u254%%u255%%u256%%u257%%u258%%u259%%u260%%u261%%u262%%u263%%u264%%u265%%u266%%u267%%u268%%u269%%u270%%u271%%u272%%u273%%u274%%u275%%u276%%u277%%u278%%u279%%u280%^
##%u281%%u282%%u283%%u284%%u285%%u286%%u287%%u288%%u289%%u290%%u291%%u292%%u293%%u294%%u295%%u296%%u297%%u298%%u299%%u300%%u301%%u302%%u303%%u304%%u305%%u306%%u307%%u308%%u309%%u310%%u311%%u312%%u313%%u314%%u315%%u316%%u317%%u318%%u319%%u320%%u321%%u322%%u323%%u324%%u325%%u326%%u327%%u328%%u329%%u330%%u331%%u332%%u333%%u334%%u335%%u336%^
##%u337%%u338%%u339%%u340%%u341%%u342%%u343%%u344%%u345%%u346%%u347%%u348%%u349%%u350%%u351%%u352%%u353%%u354%%u355%%u356%%u357%%u358%%u359%%u360%%u361%%u362%%u363%%u364%%u365%%u366%%u367%%u368%%u369%%u370%%u371%%u372%%u373%%u374%%u375%%u376%%u377%%u378%%u379%%u380%%u381%%u382%%u383%%u384%%u385%%u386%%u387%%u388%%u389%%u390%%u391%%u392%^
##%u393%%u394%%u395%%u396%%u397%%u398%%u399%%u400%%u401%%u402%%u403%%u404%%u405%%u406%%u407%%u408%%u409%%u410%%u411%%u412%%u413%%u414%%u415%%u416%%u417%%u418%%u419%%u420%%u421%%u422%%u423%%u424%%u425%%u426%%u427%%u428%%u429%%u430%%u431%%u432%%u433%%u434%%u435%%u436%%u437%%u438%%u439%%u440%%u441%%u442%%u443%%u444%%u445%%u446%%u447%%u448%^
##%u449%%u450%%u451%%u452%%u453%%u454%%u455%%u456%%u457%%u458%%u459%%u460%%u461%%u462%%u463%%u464%%u465%%u466%%u467%%u468%%u469%%u470%%u471%%u472%%u473%%u474%%u475%%u476%%u477%%u478%%u479%%u480%%u481%%u482%%u483%%u484%%u485%%u486%%u487%%u488%%u489%%u490%%u491%%u492%%u493%%u494%%u495%%u496%%u497%%u498%%u499%%u500%%u501%%u502%%u503%%u504%^
##%u505%%u506%%u507%%u508%%u509%%u510%%u511%%u512%%u513%%u514%%u515%%u516%%u517%%u518%%u519%%u520%%u521%%u522%%u523%%u524%%u525%%u526%%u527%%u528%%u529%%u530%%u531%%u532%%u533%%u534%%u535%%u536%%u537%%u538%%u539%%u540%%u541%%u542%%u543%%u544%%u545%%u546%%u547%%u548%%u549%%u550%%u551%%u552%%u553%%u554%%u555%%u556%%u557%%u558%%u559%%u560%^
###########################################################
:auto
set /A "x=%random%,x=X%%4+1"
set "newPos=!mov[%x%]!"
set /a "newPos+=Position"
if !u1! == !u%newPos%! goto :auto
set "u%position%=±"
set "position=%newPos%"
set "u!position!=#"
for %%i in (%m_%) do for /f "delims=" %%K in ('set /a "K=Position+%%i"') do if !u%%K! neq Û set "u%%K=."
for %%i in (%s_%) do for /f "delims=" %%K in ('set /a "K=Position+%%i"') do if !u%%K! neq ± if !u%%K! neq Û @set "u%%K=±"
goto :screen
:@exit /b
Phil
I am sorry, but can you explain the code a bit?
Also, how can I move on my own and not let the random-generator decide?
Thanks for helping.
Re: Problem with a game
This answer covers both the "flicker" question and this one.
The flicker on the screen mainly depends on two factors: the size of the screen area that is updated (larger areas means more flicker) and how fast the commands that update the screen are executed (faster commands means less flicker).
For example, this code:
... cause more flicker than this one:
The reason is that in the first case each line is parsed and then executed individually, so from the execution of the "cls" until the execution of the last "echo" may pass a certain time. In the second case all the lines enclosed in parentheses are first parsed as a block, and then the whole block is executed as a unit, so the time between the "cls" and the last "echo" is less than in previous example. Also, the execution of "echo." may take more time than "echo/"; the reason is explained elsewhere in this forum. Finally, if each output line would be comprised of just one variable instead of 18 its execution would be faster, because takes less time to expand one variable than 18.
This way, in order to minimize the flicker in an animated game you should try to execute the less possible number of commands in each screen refresh (from the "cls" up to the last "echo"), and execute such commands in the fastest possible way. You may review a large example of an animated game that use all these techniques in this Tetris game, that use just standard Batch commands.
Another way to minimize the flickering and play smoother animations is using external .exe programs that perform actions not available to standard Batch, like the Coulous.exe program you described. If a program can move the cursor the flicker is reduced in a large amount, because in this case the "cls" command is not longer necessary and the screen refresh just needs to update certain areas. However, the basic rules still apply: if the .exe program is a multi-purpose large application it will take more time to execute than a very small one, so smoother animations may be obtained via very small auxiliary .exe programs.
I developed a series of very efficient auxiliary .exe commands designed for its use in Batch files that allows to move the cursor, show text in color, read cursor control keys or mouse clicks, etc. A large example of a game that use such programs is this Batch file version of the 2048 game, that I think is very similar to your game in the way the keys are read and the game responds.
One problem that the auxiliary .exe files have is that the downloading of third party programs is restricted in certain places, so it is convenient to look for another way to get similar results via standard Windows features. One frequent solution is use PowerShell to read cursor keys, move the cursor or show text in color, but the PowerShell.exe application is contained in a 450 KB size file; this means that this method is slow and can not be used in games/animations.
I developed an interesting method that load the PowerShell application just once and then it is repeatedly used from the Batch file code to read keys, move cursor, show colors, etc.; you may review such method at this thread. After that, I modified the Tetris.bat game in order to use such method with very good results. I also modified the 2048.bat program, but this game was developed using auxiliary .exe commands, so in this case the modification was completed in a way that allows to select the original .exe programs or the PowerShell engine via a switch. A simple visual comparison of both methods conclude that the .exe programs one is still faster... You may review the modified version of the 2048.bat program in the same thread, below the Tetris.bat one.
Antonio
The flicker on the screen mainly depends on two factors: the size of the screen area that is updated (larger areas means more flicker) and how fast the commands that update the screen are executed (faster commands means less flicker).
For example, this code:
Code: Select all
:screen
cls
echo.
echo %u1%%u2%%u3%%u4%%u5%%u6%%u7%%u8%%u9%%u10%%u11%%u12%%u13%%u14%%u15%%u16%%u17%%u18%
echo %u19%%u20%%u21%%u22%%u23%%u24%%u25%%u26%%u27%%u28%%u29%%u30%%u31%%u32%%u33%%u34%%u35%%u36%
echo %u37%%u38%%u39%%u40%%u41%%u42%%u43%%u44%%u45%%u46%%u47%%u48%%u49%%u50%%u51%%u52%%u53%%u54%
echo %u55%%u56%%u57%%u58%%u59%%u60%%u61%%u62%%u63%%u64%%u65%%u66%%u67%%u68%%u69%%u70%%u71%%u72%
echo %u73%%u74%%u75%%u76%%u77%%u78%%u79%%u80%%u81%%u82%%u83%%u84%%u85%%u86%%u87%%u88%%u89%%u90%
... cause more flicker than this one:
Code: Select all
:screen
(
cls
echo/
echo %u1%%u2%%u3%%u4%%u5%%u6%%u7%%u8%%u9%%u10%%u11%%u12%%u13%%u14%%u15%%u16%%u17%%u18%
echo %u19%%u20%%u21%%u22%%u23%%u24%%u25%%u26%%u27%%u28%%u29%%u30%%u31%%u32%%u33%%u34%%u35%%u36%
echo %u37%%u38%%u39%%u40%%u41%%u42%%u43%%u44%%u45%%u46%%u47%%u48%%u49%%u50%%u51%%u52%%u53%%u54%
echo %u55%%u56%%u57%%u58%%u59%%u60%%u61%%u62%%u63%%u64%%u65%%u66%%u67%%u68%%u69%%u70%%u71%%u72%
echo %u73%%u74%%u75%%u76%%u77%%u78%%u79%%u80%%u81%%u82%%u83%%u84%%u85%%u86%%u87%%u88%%u89%%u90%
)
The reason is that in the first case each line is parsed and then executed individually, so from the execution of the "cls" until the execution of the last "echo" may pass a certain time. In the second case all the lines enclosed in parentheses are first parsed as a block, and then the whole block is executed as a unit, so the time between the "cls" and the last "echo" is less than in previous example. Also, the execution of "echo." may take more time than "echo/"; the reason is explained elsewhere in this forum. Finally, if each output line would be comprised of just one variable instead of 18 its execution would be faster, because takes less time to expand one variable than 18.
This way, in order to minimize the flicker in an animated game you should try to execute the less possible number of commands in each screen refresh (from the "cls" up to the last "echo"), and execute such commands in the fastest possible way. You may review a large example of an animated game that use all these techniques in this Tetris game, that use just standard Batch commands.
Another way to minimize the flickering and play smoother animations is using external .exe programs that perform actions not available to standard Batch, like the Coulous.exe program you described. If a program can move the cursor the flicker is reduced in a large amount, because in this case the "cls" command is not longer necessary and the screen refresh just needs to update certain areas. However, the basic rules still apply: if the .exe program is a multi-purpose large application it will take more time to execute than a very small one, so smoother animations may be obtained via very small auxiliary .exe programs.
I developed a series of very efficient auxiliary .exe commands designed for its use in Batch files that allows to move the cursor, show text in color, read cursor control keys or mouse clicks, etc. A large example of a game that use such programs is this Batch file version of the 2048 game, that I think is very similar to your game in the way the keys are read and the game responds.
One problem that the auxiliary .exe files have is that the downloading of third party programs is restricted in certain places, so it is convenient to look for another way to get similar results via standard Windows features. One frequent solution is use PowerShell to read cursor keys, move the cursor or show text in color, but the PowerShell.exe application is contained in a 450 KB size file; this means that this method is slow and can not be used in games/animations.
I developed an interesting method that load the PowerShell application just once and then it is repeatedly used from the Batch file code to read keys, move cursor, show colors, etc.; you may review such method at this thread. After that, I modified the Tetris.bat game in order to use such method with very good results. I also modified the 2048.bat program, but this game was developed using auxiliary .exe commands, so in this case the modification was completed in a way that allows to select the original .exe programs or the PowerShell engine via a switch. A simple visual comparison of both methods conclude that the .exe programs one is still faster... You may review the modified version of the 2048.bat program in the same thread, below the Tetris.bat one.
Antonio