NEWBIE HERE :)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Saladman
Posts: 1
Joined: 20 Nov 2019 16:22

NEWBIE HERE :)

#1 Post by Saladman » 20 Nov 2019 16:52

working on a game currently, games ok I guess, would like to make it better. here list of questions quick ones I hope

1. Whenever I see symbols like "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ" in a batch script sometimes they turn into lines or shapes but then again
sometimes they just look like random charecters, depending on the game I open, including if I copy and past them into mine I was wondering why that is.

2. one of my biggest concerns is something I've been searching all over the web for a week or two. Can you run a moving screen animation, in other words.
Can you create animation that executes multiple lines at the same time

example 1

line 1 ....o.. line 1 ...o...
line 2 ...o... line 2 ..o....
line 3 ..o.... line 3 .o.....
line 4 .o..... line 4 o...…
goto :2 goto:3

an actual working example of it being done on one command line is
for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"

<nul set/p"=[......]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[3.....]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[34....]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[342...]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[342d..]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[342do.]!CR!"
powershell Start-Sleep -m 100 >nul
<nul set/p"=[342doc]!CR!"
powershell Start-Sleep -m 100 >nul

in the example the O's have moved over one spot, is it possible to do this on multiple command lines at the same time to create what looks like an animation
using the entire screen?

thank you in advance for any help

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: NEWBIE HERE :)

#2 Post by Aacini » 21 Nov 2019 05:51

Perhaps you would like to review my Tetris game, or its Tetris in color version, or my Viboras.bat in color version of snake game...

Antonio

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: NEWBIE HERE :)

#3 Post by penpen » 21 Nov 2019 07:31

Saladman wrote:
20 Nov 2019 16:52
1. Whenever I see symbols like "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ" in a batch script sometimes they turn into lines or shapes but then again
sometimes they just look like random charecters, depending on the game I open, including if I copy and past them into mine I was wondering why that is.
The computer only is able to store data as a sequence of bytes, while you want to store text using an editor, so multiple mappings are needed to load/save such data.
Typically there are (at least) three different mappings:
- A mapping from a filename to a file (so you can access its data).
- a codepage that translates the bytestream in the file to a stream of characters (windows typically uses "UTF 16 le"), and
- a font that maps the stream of characters to an image.

In western european countries Windows typically uses codepage 1252 (also called "Latin I"), while the dos codepage is country-specific such as codepage 437 in the US and 850 in Germany.
Some Editors (like MS "Notepad.exe") are using the default windows codepage, but others (might be able to) use a different one.

In the sample case you are giving (a bunch of 'Í' characters) the following happens:
Within Nodepad you insert the character U+00CD (= "LATIN CAPITAL LETTER I WITH ACUTE") which glyph is 'Í'.
When you save your (batch) text document that character is encoded using the codepage 1252 so the file stores the byte 0xCD (hexadecmal notation).
When you are executing that batch, the cmd.exe initially is using codepage 437 (in case you are using a typical US windows installation).
Therefore the byte 0xCD is decoded into the character U+2550 ("BOX DRAWINGS DOUBLE HORIZONTAL") which is mapped to the glyph '═'.
You may change the codepage the cmd.exe is currently using by the command "chcp" (see "chcp /?" for more).

Saladman wrote:
20 Nov 2019 16:52
2. (...) Can you run a moving screen animation, in other words. Can you create animation that executes multiple lines at the same time
(...)
using the entire screen?
If you want to draw to the entire screen, then you can't use the "echo"-command, so you are stuck with the command "set /p".
If you only want to draw to any line except the last one, then echo is also okay.

There are two different general approaches (i think Aacini has linked examples for both):
- (Use cls to avoid scrolling and) Redraw the entire screen every time something has changed, or
- redraw only the changing parts, which (at the moment) only can be done in Windows 10 using VT100 codes (with disabled "Legacy console").

A reduced (nearly minimum) example for the second part is something like that (untested):

Code: Select all

@echo off
setlocal enableExtensions enableDelayedExpansion
for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"
set length=32
rem        01234567890123456789012345678901
set "data1=     sample line 01             "
set "data2=         sample line 02         "
set "data3=             sample line 03     "
set "line1=%data1%%data1%"
set "line2=%data2%%data2%"
set "line3=%data3%%data3%"
set /a "speed1=-1, speed2=+1, speed3=+2"
set /a "delta1=0, delta2=0, delta3=0"

cls
:: hide cursor
echo(%ESC%[?25l
for /l %%a in (1, 1, 64) do (
	for /f %%b in ("!delta1!") do <nul set /p "=%ESC%[10;20H!line1:~%%~b,20!
	for /f %%b in ("!delta2!") do <nul set /p "=%ESC%[11;20H!line2:~%%~b,20!
	for /f %%b in ("!delta3!") do <nul set /p "=%ESC%[12;20H!line3:~%%~b,20!
	for %%b in (1 2 3) do set /a "delta%%~b=(length+delta%%~b+speed%%~b)%%length"
	for /l %%b in (1, 1, 3000) do rem:
)
:: show cursor
echo(%ESC%[?25h

goto :eof
penpen

Newbee
Posts: 9
Joined: 12 Jun 2018 13:50

Re: NEWBIE HERE :)

#4 Post by Newbee » 21 Nov 2019 11:22

I like your wonderful minimum animation, penpen :D

Post Reply