Batch code flickers as animation changes

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Batch code flickers as animation changes

Post by MigrationUser »

21 Jul 2015 21:48
Batcher

I have a code that calls another batch file which displays an ascii art image the calls another batch file with a different image however each time the file changes the cmd window flickers how can I make it flicker free ?

----------------------------

#2 22 Jul 2015 08:34
bluesxman

It really depends on what it's doing. Presumably the animation is effected by doing a "cls" before drawing each frame. As such, it wouldn't be possible to remove the flicker entirely.

I suggest you post the code -- perhaps it can be optimised to reduce the effect.

cmd | *sh | ruby | chef

----------------------------

#3 22 Jul 2015 12:32
foxidrive

dbenham's implementation of the Snake game in a batch file is flicker free on a fast PC, and has some info in the file about how to eliminate flicker by using Aacini's free batch tools - see https://www.dostips.com/forum/viewtopic.php?f=3&t=4741

----------------------------

#4 02 Sep 2015 19:48
Batcher

ok i have to code here

Code: Select all

@echo off
cls
mode 1000
color 0a
cls
echo                                                         ```................``````                                       
echo                                                     ``..://s:::::::::::/:::::::/:-.`                                   
echo                                                 ``....-:o.-+...........:........--::-..`                 ``````````````
echo                      `.:///++++++++++ooooooooooo+//:::/so::+-----------/-------------:::-..```..--:///++oooosssssssy+-`
echo                     `syyyhhhhhhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyssssssssssssssssssssssssysssssyyyyyyyyyyhhhyyyyyyyho/+/ 
echo                     `oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyysyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/`   
echo                      -yyyyyyyydddddddhyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhhhyo-.
echo                      .:////o+mNmysysymmdyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhhhyy+s`
echo                      `://::+yNmsshyhosNNhsyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyhyyyyyyyhhhhyyyyhyyyyyyyyyyyyyyyso-
echo                             oNNyyhhhyhNNo`:oosssssssssssssssyyyyyyyyyyyyyyyyyyyyyyyyyommhyhhhhhdmy/+++++++++++++++++/. 
echo                             `oNNmmmmmNNs`                  `````````````````````````` +mNmmmmmNNy`                     
echo                               ./shhhs+.                                                `/syhhs+.



rem 10000 is 10,000 millisecons 0r 10 seconds 1000 is 1 second use 1000 not 10,000
ping 192.0.2.2 -n 1 -w 1000 > nul
@echo off
mode 1000
call car4
car4.bat is in the same folder and is the same file with the car moved over one tab i dont know if 1 tab is to much or 1 second is to long.

----------------------------

#5 02 Sep 2015 22:32
Aacini

You may minimize the flicker if change the screen size to minimum and show the next image immediately after a CLS:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set n=0
for %%a in (
"                                    ```................``````                                       "
"                                ``..://s:::::::::::/:::::::/:-.`                                    "
"                            ``....-:o.-+...........:........--::-..`                 `````````````` "
" `.:///++++++++++ooooooooooo+//:::/so::+-----------/-------------:::-..```..--:///++oooosssssssy+-` "
"`syyyhhhhhhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyssssssssssssssssssssssssysssssyyyyyyyyyyhhhyyyyyyyho/+/  "
"`oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyysyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/`   "
" -yyyyyyyydddddddhyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhhhyo-. "
" .:////o+mNmysysymmdyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyhhhyy+s`"
" `://::+yNmsshyhosNNhsyyyyyyyyyhyyyyyyyyyyyyyyyyyyyyhyyyyyyyyyyyhyyyyyyyhhhhyyyyhyyyyyyyyyyyyyyyso- "
"        oNNyyhhhyhNNo`:oosssssssssssssssyyyyyyyyyyyyyyyyyyyyyyyyyommhyhhhhhdmy/+++++++++++++++++/.  "
"        `oNNmmmmmNNs`                  `````````````````````````` +mNmmmmmNNy`                      "
"          ./shhhs+.                                                `/syhhs+.                        "
) do (
   set /A n+=1
   set "car[!n!]=%%~a"
)

set "spaces= "
for /L %%i in (1,1,100) do set "spaces=!spaces! "

color 0a
set /A lines=n+2
mode con cols=102 lines=%lines%

for /L %%m in (10,10,100) do (
   cls
   for /L %%i in (1,1,%n%) do (
      echo/!spaces:~%%m!!car[%%i]:~0^,%%m!
   )
   ping 192.0.2.2 -n 1 -w 1000 > nul
)
For example, in previous code you may minimize the flicker even more (or use a larger window) if several complete output files are prepared in advance and then displayed in a loop via:

Code: Select all

for /L %%i in (1,1,10) do (
   cls
   type file%%i.txt
   ping 192.0.2.2 -n 1 -w 1000 > nul
)
... instead of generate each output screen in a FOR loop.

Antonio

----------------------------

#6 03 Sep 2015 17:18
freakinghorny

ohh it is really a car dos car.....great smile

----------------------------

#7 13 Sep 2015 15:36
Batcher

Thank you Aacini this works perfectly but I have another question about this code is it possible to make the car "drive" backwards thanks

----------------------------

#8 15 Sep 2015 03:31
Shadow Thief

Change

Code: Select all

for /L %%m in (10,10,100) do (
to

Code: Select all

for /L %%m in (100,-10,10) do (
----------------------------

#9 26 Sep 2015 21:20
Batcher

Just another question is there a way to change the car to text from a text file thanks

----------------------------

#10 27 Sep 2015 03:09
Shadow Thief

Code: Select all

for /f "delims=" %%A in (car.txt)
----------------------------

#11 27 Sep 2015 19:22
Batcher

Where would I put
for /f "delims=" %%A in (car.txt)

----------------------------

#12 28 Sep 2015 14:11
Shadow Thief

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set n=0
for /f "delims=" %%a in (car.txt) do (
   set /A n+=1
   set "car[!n!]=%%~a"
)

set "spaces= "
for /L %%i in (1,1,100) do set "spaces=!spaces! "

color 0a
set /A lines=n+2
mode con cols=102 lines=%lines%

for /L %%m in (10,10,100) do (
   cls
   for /L %%i in (1,1,%n%) do (
      echo/!spaces:~%%m!!car[%%i]:~0^,%%m!
   )
   ping 192.0.2.2 -n 1 -w 1000 > nul
)
Post Reply