Off Topic Stuff

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
penpen
Expert
Posts: 1988
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Off Topic Stuff

#16 Post by penpen » 08 Jan 2014 08:33

It seems to be fast enough.
But the program logic still is completely missing, so i don't know how fast it were in the result.
Nevertheless it is a nice option.

penpen

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Off Topic Stuff

#17 Post by einstein1969 » 08 Jan 2014 10:08

I added the frog in one of the worst cases. On my pc it seems there is still a good margin. The logic is some set /a with a bit operations if we use a binary matrix for collisions and shifts.

Code: Select all

@echo off & setlocal enableDelayedExpansion

set /a cols=80,lines=43

rem color
pushd "%temp%"
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
For /L %%c in (1,1,%cols%) do set "str_findstr=!str_findstr!L"
For /L %%l in (1,1,%cols%) do <nul set /p .=%BS%> "!str_findstr:~0,%%l!"

cls & mode %cols%,%lines% & color 07


:output

rem set "line_0_1=²²²²²² É» ²²²²²²²²²²²²    ²²²²²²²²²²²²    ²²²²²²²²²²²²    ²²²²²²²²²²²²    ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²"
rem set "line_0_2=²²²²²²ÊÊÊʲ²²²²²²²²²²²    ²²²²²²²²²²²²    ²²²²²²²²²²²²    ²²²²²²²²²²²²   
set "line_0_1=%BS%"
set "line_0_2=%BS%"
set "line_1_1=            ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍ»            ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍ»            ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍ»            ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍ»"
set "line_1_2=            ÈÍÊÍÍÍÍÍÍÍÍÍÍÍͼ            ÈÍÊÍÍÍÍÍÍÍÍÍÍÍͼ            ÈÍÊÍÍÍÍÍÍÍÍÍÍÍͼ            ÈÍÊÍÍÍÍÍÍÍÍÍÍÍͼ"
set "line_2_1=ÜÜ////ÜÜ////            ÜÜ////ÜÜ////ÜÜ////ÜÜ////                ÜÜ////ÜÜ////ÜÜ////ÜÜ////            ÜÜ////ÜÜ////"
set "line_2_2=ßß\\\\ßß\\\\            ßß\\\\ßß\\\\ßß\\\\ßß\\\\                ßß\\\\ßß\\\\ßß\\\\ßß\\\\            ßß\\\\ßß\\\\"
set "line_3_1=ÍÍÍÍÍ»          ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»          ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»        ÉÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
set "line_3_2=ÍÍÍÍͼ          ÈÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ          ÈÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ        ÈÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
set "line_4_1=ÉÍËÍÍÍÍÍÍÍÍÍÍ»        ÉÍËÍÍÍÍÍÍÍÍÍÍ»        ÉÍËÍÍÍÍÍÍÍÍÍÍ»        ÉÍËÍÍÍÍÍÍÍÍÍÍ»          ÉÍËÍÍÍÍÍÍÍÍÍÍ»        "
set "line_4_2=ÈÍÊÍÍÍÍÍÍÍÍÍͼ        ÈÍÊÍÍÍÍÍÍÍÍÍͼ        ÈÍÊÍÍÍÍÍÍÍÍÍͼ        ÈÍÊÍÍÍÍÍÍÍÍÍͼ          ÈÍÊÍÍÍÍÍÍÍÍÍͼ        "
set "line_5_1=//ÜÜ////ÜÜ////          ÜÜ////ÜÜ////ÜÜ////          ÜÜ////ÜÜ////ÜÜ////          ÜÜ////ÜÜ////ÜÜ////          ÜÜ//"
set "line_5_2=\\ßß\\\\ßß\\\\          ßß\\\\ßß\\\\ßß\\\\          ßß\\\\ßß\\\\ßß\\\\          ßß\\\\ßß\\\\ßß\\\\          ßß\\"
rem set "line_6_1=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
rem set "line_6_2=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
set "line_6_1=%BS%"
set "line_6_2=%BS%"
set "line_7_1=                ÜÜ_ÜÜÜÜÜ                ÜÜ_ÜÜÜÜÜ                                        ÜÜ_ÜÜÜÜÜ                "
set "line_7_2=                ßßîßßßßß                ßßîßßßßß                                        ßßîßßßßß                "
set "line_8_1=                  ÌÄ=ÂÂÄ=¿        ÌÄ=ÂÂÄ=¿                                            ÌÄ=ÂÂÄ=¿                  "
set "line_8_2=                  ÌÄ=ÁÁÄ=Ù        ÌÄ=ÁÁÄ=Ù                                            ÌÄ=ÁÁÄ=Ù                  "
set "line_9_1=            ÚÄËÄË¿                                ÚÄËÄË¿                          ÚÄËÄË¿                        "
set "line_9_2=            ÀÄÊÄÊÙ                                ÀÄÊÄÊÙ                          ÀÄÊÄÊÙ                        "
set "line_10_1=          ÜÄÄÜÜÜ_/              ÜÄÄÜÜÜ_/              ÜÄÄÜÜÜ_/              ÜÄÄÜÜÜ_/                ÜÄÄÜÜÜ_/    "
set "line_10_2=          ßÄÄßßßî\              ßÄÄßßßî\              ßÄÄßßßî\              ßÄÄßßßî\                ßÄÄßßßî\    "
rem set "line_11_1=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
rem set "line_11_2=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
set "line_11_1=%BS%"
set "line_11_2=%BS%"

set "frog_1_0= Ú¿ "
set "frog_2_0=ÁÁÁÁ"
set "frog_1_1= ÌÄ¿"
set "frog_2_1= ÌÄÙ"
set "frog_1_2=ÂÂÂÂ"
set "frog_2_2= ÀÙ "
set "frog_1_3=ÚĹ "
set "frog_2_3=ÀĹ "

:: lines are all 112 characters long
set "LINE_LENGTH=112"
set /A "speed_0=0", "speed_1=-1", "speed_2=1", "speed_3=-1", "speed_4=-1", "speed_5=1"
set /A "speed_6=0", "speed_7=1", "speed_8=-2", "speed_9=2", "speed_10=-1", "speed_11=0"
for /L %%a in (0,1,11) do set /A "offset_%%a=0"


set /A "NORTH=0", "EAST=1", "SOUTH=2", "WEST=3"
set /A "frog.head=!NORTH!"


:next

rem 4 c e a 2 1 5

echo(
<nul set /p "=%BS%  " & call :ColorText_bg_BS 4 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS c 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS e 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS a 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 2 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 1 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 5 76

echo(
echo(
<nul set /p "=%BS%  " & call :ColorText_bg_BS 2 6 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 3 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 2 6 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 13 & call :ColorText_bg_BS 0 5 & call :ColorText_bg_BS 2 3 /N

For /L %%n in (1,1,10) do echo(
call :ColorText_bg_BS a 78 /N
call :ColorText_bg_BS a 78
For /L %%n in (1,1,9) do echo(
call :ColorText_bg_BS 5 78 /N
call :ColorText_bg_BS 5 78 /n

echo(
echo(
<nul set /p "=%BS%  " & call :ColorText_bg_BS 5 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 1 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 2 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS a 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS e 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS c 76 /N
<nul set /p "=%BS%  " & call :ColorText_bg_BS 4 76


set "T1=%TIME%"
set /A "N=112*2"
for /L %%k in (0,1,%N%) do (
rem   cls
mode %cols%,%lines%
for /L %%L in (1,1,8) do echo(
rem   echo 0 0
rem   (
      set "status=                                                                               %%k/%N%"
      echo(!status:~-78!
      for /L %%l in (0,1,11) do (
         set /A "frame=((%%k%%!LINE_LENGTH!)*!speed_%%l!)%%!LINE_LENGTH!"
::         echo set /A "frame=((%%k%%!LINE_LENGTH!)*!speed_%%l!)%%!LINE_LENGTH!", !frame!
         for /F %%f in ("!frame!") do (
            set "l_1=!line_%%l_1:~%%f!!line_%%l_1!"
            set "l_2=!line_%%l_2:~%%f!!line_%%l_2!"
         )
         if %%l equ 6 (
      set /a "posx=%%k %% 73+2, posx1=posx-1"
      <nul set /p "=%BS%  " & call :ColorText_bg_BS a !posx!  &  echo(É»
      <nul set /p "=%BS%  " & call :ColorText_bg_BS a !posx1! & echo(ÊÊÊÊ
    ) else (
           echo(  !l_1:~0,76!
           echo(  !l_2:~0,76!
         )
      )
rem   ) > CON
   pause
   rem ping 192.0.2.0 -n 1 -w 500 >nul
)

(
   echo   %T1%
   echo   %TIME%
) > CON

popd
goto :eof


:ColorText_bg_BS bg_color len [/n]
(   
  set /a "len=%2-1"
  if %1 equ 0 (set fg=1) else set fg=%1
  if !len! geq 1 for %%. in (!len!) do  findstr /v /a:%1!fg! /R "^$" "!str_findstr:~0,%%.!" nul
  if /i "%~3"=="/n" echo(
goto :eof
)


EDIT: It is not the worst case.

einstein1969

Post Reply