|
71
|
Programacin / Scripting / Re: [Batch] Vaciar Papelera de Reciclaje
|
en: 7 Marzo 2009, 03:52 am
|
hay forma de hacerlo obteniendo la credencial de usuario y entrando hasta la carpeta recycler para borrar todo su contenido...todo en un simple BAT...sin necesidad de usar herramientas externas....
Saludos.
|
|
|
73
|
Programacin / Scripting / [Batch Game] PingPong v 1 - by :: SmartGenius ::
|
en: 24 Enero 2009, 20:14 pm
|
Bueno, que mas decirles.....otro Juego Batch mas a la lista Ping Pong v 1Descargar: http://one.xthost.info/smartv2/BatchGames/PingPong_bySmartGenius.zip (incluido CHOICE.COM) Este es un juego similar al PingPong que alguna vez jugaron en las consolas, solo que en este la PC es invencible ...auqnue eso lo podria modificar. Controles:
Tecla "W" = Iniciar Juego / Acelerar la Bola Tecla "A" = Mover Tabla a la Izquierda Tecla "D" = Mover Tabla a la Derecha Tecla "X" = Salir de JuegoAqui el Codigo usado......en Base a lo aprendido con el tema de Graficos y Coordenadas. @echo off @title PingPong v 1 @mode con cols=28 lines=24 @::Juego Batch PingPong @::Another Batch Game @::by ::SmartGenius ::
if not exist "choice.com" (Goto :NoKey)
:load call :Logo setlocal enabledelayedexpansion set LimX=18 set LimY=16 set TBound=3 set LBound=1 set /a RBound=%LimX%-1 set /a BBound=%LimY%-3 set NLevels=1
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b= )) set Ball=O set Bound= set Block= set Line= set Lost=
:Levels set /a L+=1 Call :Level%L% Call :Graphic set P%L%=%Movs% if "%LOS%"=="True" Goto :Lost if "%NXL%"=="True" Goto :End if "%L%"=="%NLevels%" Goto :Win ping -n 1 0.0.0.0 >nul Goto :Init
:Graphic Call :Clear cls for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d!)) echo. echo. PingPong v 1 by Smart echo. echo. PC:%PPC% Player:%Points% echo. ͻ for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) echo. ͼ rem pause >nul call :%Action% if "%PPC%"=="10" (Set LOS=True&set NXL=True) if "%NXL%"=="True" (Goto :Eof) Goto :Graphic
:Paused CHOICE /C:WADX /N >nul if "%errorlevel%"=="1" (set Action=Playing) if "%errorlevel%"=="2" (call :LeftA) if "%errorlevel%"=="3" (call :RightA) if "%errorlevel%"=="4" (set NXL=True) Call :MovPC "%CurPos%" Goto :Eof
:Playing CHOICE /C:WADX /N /T:W,1 >nul if "%errorlevel%"=="1" (set Action=Playing) if "%errorlevel%"=="2" (call :LeftB) if "%errorlevel%"=="3" (call :RightB) if "%errorlevel%"=="4" (set NXL=True) Call :MovBall Call :MovPC "%CurPos%" Goto :Eof
::Logica de Movimiento en el Plano ::Coded by :: SmartGenius ::
:RightA if ["%Table%"]==["%MaxTable%"] (Goto :Eof) for /f "tokens=1,5 delims=," %%u in ("%Table%") do ( call :MovAX+ "%%u" "%%v" TB "!%%u!" call set NewTable=!TB!,%Table% for /f "tokens=1-5 delims=," %%t in ("!NewTable!") do (set NewTable=%%t,%%u,%%v,%%w,%%x) set Table=!NewTable! call :MovAX+ "%CurPos%" "%CurPos%" CurPos "!%CurPos%!" ) Goto :Eof
:MovAX+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p+1 call set NMovX=%%X!MovX!Y%%q%% if "!NMovX!"=="%Bound%" (Goto :Eof) if "!NMovX!"==" " ( set %~2= set X!MovX!Y%%q=%~4 set %3=X!MovX!Y%%q)) Goto :Eof
:RightB if ["%Table%"]==["%MaxTable%"] (Goto :Eof) for /f "tokens=1,5 delims=," %%u in ("%Table%") do ( call :MovAX+ "%%u" "%%v" TB "!%%u!" call set NewTable=!TB!,%Table% for /f "tokens=1-5 delims=," %%t in ("!NewTable!") do (set NewTable=%%t,%%u,%%v,%%w,%%x) set Table=!NewTable!) Goto :Eof
:LeftA if ["%Table%"]==["%MinTable%"] (Goto :Eof) for /f "tokens=1,5 delims=," %%u in ("%Table%") do ( call :MovAX- "%%v" "%%u" TB "!%%v!" call set NewTable=%Table%,!TB! for /f "tokens=2-6 delims=," %%t in ("!NewTable!") do (set NewTable=%%t,%%u,%%v,%%w,%%x) set Table=!NewTable! call :MovAX- "%CurPos%" "%CurPos%" CurPos "!%CurPos%!" ) Goto :Eof
:LeftB if ["%Table%"]==["%MinTable%"] (Goto :Eof) for /f "tokens=1,5 delims=," %%u in ("%Table%") do ( call :MovAX- "%%v" "%%u" TB "!%%v!" call set NewTable=%Table%,!TB! for /f "tokens=2-6 delims=," %%t in ("!NewTable!") do (set NewTable=%%t,%%u,%%v,%%w,%%x) set Table=!NewTable!) Goto :Eof
:MovAX- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p-1 call set NMovX=%%X!MovX!Y%%q%% if "!NMovX!"=="%Bound%" (Goto :Eof) if "!NMovX!"==" " ( set %~2= set X!MovX!Y%%q=%~4 set %3=X!MovX!Y%%q)) Goto :Eof
:MovPC for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( for /l %%x in (%LBound%,1,%RBound%) do (set X%%xY2= ) set /a PCL=%%p-2 set /a PCR=%%p+2 for /l %%s in (!PCL!,1,!PCR!) do (set X%%sY2=%Bound%)) Goto :Eof
:MovBall set EOM=False Call :%NextMov% "%CurPos%" if "%EOM%"=="True" Goto :Eof Goto :MovBall
::Moviemtos Diagonales de la Bola ::Movimiento Diagonal1 :Diag1 for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p+1 set /a MovY=%%q+1 call set NMovXY=%%X!MovX!Y!MovY!%%
if "!NMovXY!"=="%Bound%" ( if "%%q"=="%BBound%" (set NextMov=Diag3) if "%%p"=="%RBound%" (set NextMov=Diag4) Goto :Eof)
if "!NMovXY!"==" " ( set %~1= set X!MovX!Y!MovY!=%Ball% set CurPos=X!MovX!Y!MovY! set EOM=True) )
if "!NMovXY!"=="%Lost%" ( set %~1= set /a PPC+=1 call :Reset set EOM=True) ) Goto :Eof
::Movimiento Diagonal2 :Diag2 for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p-1 set /a MovY=%%q-1 call set NMovXY=%%X!MovX!Y!MovY!%%
if "!NMovXY!"=="%Bound%" ( if "%%q"=="%TBound%" (set NextMov=Diag4) if "%%p"=="%LBound%" (set NextMov=Diag3) Goto :Eof)
if "!NMovXY!"==" " ( set %~1= set X!MovX!Y!MovY!=%Ball% set CurPos=X!MovX!Y!MovY! set EOM=True) )
if "!NMovXY!"=="%Lost%" ( set %~1= set /a Points+=1 call :Reset set EOM=True) ) Goto :Eof
::Movimiento Diagonal3 :Diag3 for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p+1 set /a MovY=%%q-1 call set NMovXY=%%X!MovX!Y!MovY!%%
if "!NMovXY!"=="%Bound%" ( if "%%q"=="%TBound%" (set NextMov=Diag1) if "%%p"=="%RBound%" (set NextMov=Diag2) Goto :Eof)
if "!NMovXY!"==" " ( set %~1= set X!MovX!Y!MovY!=%Ball% set CurPos=X!MovX!Y!MovY! set EOM=True) )
if "!NMovXY!"=="%Lost%" ( set %~1= set /a Points+=1 call :Reset set EOM=True) ) Goto :Eof
::Movimiento Diagonal4 :Diag4 for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p-1 set /a MovY=%%q+1 call set NMovXY=%%X!MovX!Y!MovY!%%
if "!NMovXY!"=="%Bound%" ( if "%%q"=="%BBound%" (set NextMov=Diag2) if "%%p"=="%LBound%" (set NextMov=Diag1) Goto :Eof)
if "!NMovXY!"==" " ( set %~1= set X!MovX!Y!MovY!=%Ball% set CurPos=X!MovX!Y!MovY! set EOM=True) )
if "!NMovXY!"=="%Lost%" ( set %~1= set /a PPC+=1 call :Reset set EOM=True) ) Goto :Eof
:Clear for /l %%m in (0,1,%LimY%) do (set Lin_%%m=) Goto :Eof
:Reset set CurPos=X8Y13 set Table=X10Y14,X9Y14,X8Y14,X7Y14,X6Y14 for /l %%h in (1,1,17) do (set X%%hY14= ) for %%k in (%Init%) do (set %%k=%Line%) for /f "tokens=1 delims=," %%j in ("%Init%") do (set %%j=%Ball%) set Action=Paused Goto :Eof
:Lost msg * Perdiste !
:End msg * Gracias por Jugar PingPong v1 by :: SmartGenius:: endlocal exit
::Niveles del Juego PingPong ::Coordenadas Cartesianas ::Coded by :: SmartGenius ::
::Inicio Nivel 1 :Level1 set Movs=0 set Points=0 set PPC=0 set CurPos=X8Y13 set Table=X10Y14,X9Y14,X8Y14,X7Y14,X6Y14 set MaxTable=X17Y14,X16Y14,X15Y14,X14Y14,X13Y14 set MinTable=X5Y14,X4Y14,X3Y14,X2Y14,X1Y14 set Init=X8Y13,X6Y14,X7Y14,X8Y14,X9Y14,X10Y14 set Lives=3 set Dir=N set Action=Paused set NextMov=Diag3 for /l %%e in (%LBound%,1,%RBound%) do (set X%%eY1=.) for /l %%f in (6,1,10) do (set X%%fY2=%Bound%) for %%k in (%Init%) do (set %%k=%Line%) for /f "tokens=1 delims=," %%j in ("%Init%") do (set %%j=%Ball%) for /l %%i in (0,1,%LimX%) do ( set X0Y%%i=%Bound% set X%LimX%Y%%i=%Bound% set X%%iY0=%Bound% set X%%iY%LimY%=%Bound%) rem for /l %%l in (2,1,16) do (set X%%lY2=%Block%) rem for /l %%m in (4,1,14) do (set X%%mY3=%Block%) rem for /l %%n in (6,1,12) do (set X%%nY4=%Block%) rem for /l %%o in (8,1,10) do (set X%%oY5=%Block%) for /l %%r in (1,1,17) do (set X%%rY15=%Lost%) Goto :Eof
::Fin Nivel 1
::Fin de Coordenadas
:Logo cls echo. echo. echo. echo. ۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰ echo. ۰۰۰۰۰ echo. echo. echo. echo. ۰۰۰۰ echo. ۰۰۲۰۰۰۰ echo. ۰۰۰۱۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۲۰۰۰۰ echo. ۰۰۰۰ echo. ۰ echo. echo. : SmartGenius : echo. Corp. 2009 echo. ping -n 3 0.0.0.0 >nul Goto :Eof
:NoKey @mode con cols=30 lines=20 cls echo. echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo encuentra. echo. echo CHOICE.COM echo. echo Por favor descargue una copia del Comando echo CHOICE de Internet... echo. pause exit
Cualquier duda, comentario o sugerencia es Bienvenida..... Que lo disfruten...y un Saludo
|
|
|
76
|
Programacin / Scripting / [Batch Game] PacMan v 1 - by :: SmartGenius ::
|
en: 22 Enero 2009, 22:51 pm
|
Bueno, de nuevo llevando a la practica el Tema de los Graficos en Batch, y una que otra cosita que he aprendido, pues les traigo otro Clasico de los Gamers...en Batch !!! Pacman v 1Es el Clasico Juego de PacMan en el que tienes que atravesar un Puzzle mientras recoges "Galletas" y vas acumulando puntos, pero teniendo cuidado con los Fantasmas..... EL Juego hace uso de CHOICE Descargar: PacManv1bySmart.zip (CHOICE Incluido) @echo off @title PacMan v 1 @mode con cols=24 lines=24 @::Juego Batch PacMan @::Another Batch Game @::by ::SmartGenius ::
if not exist "choice.com" (Goto :NoKey)
:load call :Logo setlocal enabledelayedexpansion set LimX=16 set LimY=16 set NLevels=1
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b=.)) set Player= set Bound= set Box= set Ghost=
:Levels set /a L+=1 Call :Level%L% Call :Graphic set P%L%=%Movs% if "%NXL%"=="True" Goto :End if "%L%"=="%NLevels%" Goto :Win ping -n 1 0.0.0.0 >nul Goto :Init
:Graphic Call :Clear cls for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d!)) echo. echo. Pacman v 1 by Smart echo. echo. Vidas:%Lives% Puntos:%Points% echo. ͻ for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) echo. ͼ CHOICE /C:WASDX /N /T:%Dir%,1 >nul if "%errorlevel%"=="1" (call :MovY- "%CurPos%" CurPos&set Dir=W) if "%errorlevel%"=="2" (call :MovX- "%CurPos%" CurPos&set Dir=A) if "%errorlevel%"=="3" (call :MovY+ "%CurPos%" CurPos&set Dir=S) if "%errorlevel%"=="4" (call :MovX+ "%CurPos%" CurPos&set Dir=D) if "%errorlevel%"=="5" (set NXL=True&Goto :Eof) Call :MovGhost for %%w in (%Boxes%) do ( if not "!%%w!"=="%Box%" ( if "!%%w!"=="." (set %%w=%Box%))) set /a NCK=%Points% %% 7 if "%NCK%"=="0" set Cki=False if "%EOG%"=="True" (msg * Perdiste&Goto :Eof) Goto :Graphic
::Logica de Movimiento en el Plano ::Coded by :: SmartGenius ::
:MovX+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p+1 call set NMovX=%%X!MovX!Y%%q%%
if "!NMovX!"=="%Bound%" (Goto :Eof)
if "!NMovX!"=="%Ghost%" ( if !%~1!==%Player% ( if "%Cki%"=="True" ( set %~1= set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q set /a Points+=10 call :UnGhost "X!MovX!Y%%q" ) if "%Cki%"=="False" ( set %~1= set /a Lives-=1 set %Init%=%Player% set %2=%Init% if "!Lives!"=="0" (set EOG=True) )))
if "!NMovX!"=="." ( if !%~1!==%Player% ( set %~1= set /a Points+=2 set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1=. set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q))
if "!NMovX!"==" " ( if !%~1!==%Player% ( set %~1= set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1= set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q))
if "!NMovX!"=="%Box%" ( if !%~1!==%Player% ( set %~1= set /a Points+=5 set Cki=True set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1=. set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q)))
if !%~1!==%Player% set /a Movs+=1 Goto :Eof
:MovX- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovX=%%p-1 call set NMovX=%%X!MovX!Y%%q%%
if "!NMovX!"=="%Bound%" (Goto :Eof)
if "!NMovX!"=="%Ghost%" ( if !%~1!==%Player% ( if "%Cki%"=="True" ( set %~1= set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q set /a Points+=10 call :UnGhost "X!MovX!Y%%q" ) if "%Cki%"=="False" ( set %~1= set /a Lives-=1 set %Init%=%Player% set %2=%Init% if "!Lives!"=="0" (set EOG=True) )))
if "!NMovX!"=="." ( if !%~1!==%Player% ( set %~1= set /a Points+=2 set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1=. set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q))
if "!NMovX!"==" " ( if !%~1!==%Player% ( set %~1= set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1= set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q))
if "!NMovX!"=="%Box%" ( if !%~1!==%Player% ( set %~1= set /a Points+=5 set Cki=True set X!MovX!Y%%q=%Player% set %2=X!MovX!Y%%q) if !%~1!==%Ghost% ( set %~1=. set X!MovX!Y%%q=%Ghost% set %2=X!MovX!Y%%q)))
if !%~1!==%Player% set /a Movs+=1 Goto :Eof
:MovY+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovY=%%q+1 call set NMovY=%%X%%pY!MovY!%%
if "!NMovY!"=="%Bound%" (Goto :Eof)
if "!NMovY!"=="%Ghost%" ( if !%~1!==%Player% ( if "%Cki%"=="True" ( set %~1= set X%%pY!MovY!=%Player% set %2=X%%pY!MovY! set /a Points+=10 call :UnGhost "X%%pY!MovY!" ) if "%Cki%"=="False" ( set %~1= set /a Lives-=1 set %Init%=%Player% set %2=%Init% if "!Lives!"=="0" (set EOG=True) )))
if "!NMovY!"=="." ( if !%~1!==%Player% ( set %~1= set /a Points+=2 set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1=. set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!))
if "!NMovY!"==" " ( if !%~1!==%Player% ( set %~1= set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1= set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!))
if "!NMovY!"=="%Box%" ( if !%~1!==%Player% ( set %~1= set /a Points+=5 set Cki=True set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1=. set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!)))
if !%~1!==%Player% set /a Movs+=1 Goto :Eof
:MovY- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( set /a MovY=%%q-1 call set NMovY=%%X%%pY!MovY!%%
if "!NMovY!"=="%Bound%" (Goto :Eof)
if "!NMovY!"=="%Ghost%" ( if !%~1!==%Player% ( if "%Cki%"=="True" ( set %~1= set X%%pY!MovY!=%Player% set %2=X%%pY!MovY! set /a Points+=10 call :UnGhost "X%%pY!MovY!" ) if "%Cki%"=="False" ( set %~1= set /a Lives-=1 set %Init%=%Player% set %2=%Init% if "!Lives!"=="0" (set EOG=True) )))
if "!NMovY!"=="." ( if !%~1!==%Player% ( set %~1= set /a Points+=2 set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1=. set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!))
if "!NMovY!"==" " ( if !%~1!==%Player% ( set %~1= set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1= set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!))
if "!NMovY!"=="%Box%" ( if !%~1!==%Player% ( set %~1= set /a Points+=5 set Cki=True set X%%pY!MovY!=%Player% set %2=X%%pY!MovY!) if !%~1!==%Ghost% ( set %~1=. set X%%pY!MovY!=%Ghost% set %2=X%%pY!MovY!)))
if !%~1!==%Player% set /a Movs+=1 Goto :Eof
:MovGhost set NGG=0 for %%z in (%Ghosts%) do ( set /a NG+=1 set Ghost!NG!=%%z) :MovGhost2 set /a NGG+=1 set /a GoMov=%random:~-1% %% 4 if "!GoMov!"=="0" Call :MovX+ %%Ghost!NGG!%% Ghost!NGG! if "!GoMov!"=="1" Call :MovX- %%Ghost!NGG!%% Ghost!NGG! if "!GoMov!"=="2" Call :MovY+ %%Ghost!NGG!%% Ghost!NGG! if "!GoMov!"=="3" Call :MovY- %%Ghost!NGG!%% Ghost!NGG! ) if "%NGG%"=="4" ( set Ghosts=%Ghost1%,%Ghost2%,%Ghost3%,%Ghost4% set NG=0 Goto :Eof) Goto :MovGhost2
:UnGhost set Ghosts=!Ghosts:%~1=X8Y7! for %%g in (%Ghosts%) do (set %%g=%Ghost%) Goto :Eof
:Clear for /l %%m in (0,1,%LimY%) do (set Lin_%%m=) Goto :Eof
:Win
:End msg * Gracias por Jugar PacMan v1 by :: SmartGenius:: endlocal exit
::Niveles del Juego PacMan ::Coordenadas Cartesianas ::Coded by :: SmartGenius ::
::Inicio Nivel 1 :Level1 set Movs=0 set Points=0 set X2Y15=%Player% set CurPos=X2Y15 set Init=X2Y15 set Lives=3 set Cki=False set Dir=D set Ghosts=X2Y11,X6Y9,X6Y7,X10Y6 set Boxes=X2Y1,X2Y9,X14Y1,X14Y9,X14Y15 for %%g in (%Ghosts%) do (set %%g=%Ghost%) for %%h in (%Boxes%) do (set %%h=%Box%) for /l %%i in (0,1,16) do ( set X0Y%%i=%Bound% set X1Y%%i=%Bound% set X15Y%%i=%Bound% set X16Y%%i=%Bound% set X%%iY0=%Bound% set X%%iY16=%Bound%) for %%j in (3,4,5,6,10,11,12,13) do ( set X%%jY2=%Bound% set X%%jY3=%Bound% set X%%jY10=%Bound% set X%%jY14=%Bound%) for %%k in (X8Y1,X8Y2,X8Y3,X3Y5,X3Y6,X3Y7,X3Y8,X5Y5,X5Y6,X5Y7,X5Y8,X6Y5,X7Y5) do (set %%k=%Bound%) for %%l in (X6Y8,X7Y8,X8Y8,X9Y8,X10Y8,X9Y5,X10Y5,X11Y5,X11Y6,X11Y7,X11Y8,X13Y5) do (set %%l=%Bound%) for %%m in (X13Y6,X13Y7,X13Y8,X7Y10,X9Y10,X3Y12,X3Y13,X5Y12,X6Y12,X7Y12,X8Y12) do (set %%m=%Bound%) for %%n in (X9Y12,X10Y12,X11Y12,X8Y13,X8Y14,X13Y12,X13Y13) do (set %%n=%Bound%) for %%o in (X6Y6,X7Y6,X8Y5,X8Y6,X9Y6,X7Y7,X8Y7,X9Y7,X10Y7) do (set %%o= ) Goto :Eof
::Fin Nivel 1
::Fin de Coordenadas
:Logo color 0a cls echo. echo. echo. echo. ۰۰۰ echo. ۰۰۰۰۰ echo. ۰۰۰۰۰ echo. ۰۰۰ echo. ۰۰۰۰ echo. ۰۰۰۰ echo. ۰۰۰۰ echo. echo. ۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰ echo. ۰۰۰۰۰۰۰ echo. ۰۰۰۰۰۰ echo. ۰۰۰۰۰۰ echo. echo. echo. : SmartGenius : echo. Corp. 2009 echo. ping -n 3 0.0.0.0 >nul color 0e Goto :Eof
:NoKey @mode con cols=30 lines=20 cls echo. echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo encuentra. echo. echo CHOICE.COM echo. echo Por favor descargue una copia del Comando echo CHOICE de Internet... echo. pause exit
Con esto queda demostrado que se pueden hacer bastantes cosas en Batch, solo hace falta imaginacion y algo de tiempo.... Cualquier duda, comentario o sugerencia acerca del codigo hacerla por favor... Saludos.
|
|
|
77
|
Programacin / Scripting / [Batch Game] PushBox v 1 - by :: SmartGenius ::
|
en: 16 Enero 2009, 19:49 pm
|
Siguiendo con la Aplicacion del Concepto de Coordenadas y Graficos en Batch Desarrollado por Mi... 8)...pues les vengo a presentar un Nuevo Juego que he ideado...para su Deleite.... PushBox v 1 - by SmartSe trata de un Juego en el cual controlas a un Jugador en una Especie de Laberinto, el cual tienes que guiar y hacer que Empuje (Push) unas Cajas (Box) hasta hacerlas llegar a unas posiciones predeterminadas, todo esto hacerlo en la menor cantidad de Movimientos. Controles
Arriba: Flecha Arriba Abajo: Flecha Abajo Derecha: Flecha Derecha Izquierda: Flecha Izquierda Salir: Tecla "X"
Codigo: @mode con cols=21 lines=18 @::Another Batch Game @::by ::SmartGenius :: :load :init :Levels if " %L%"==" %NLevels%" Goto : Win :Graphic :First cls set Lin_ %%d= !Lin_%% style="color: #448888;">d!!X%%eY%%d!)) echo. PushBox v1 by Smart echo. Nivel: %L% Movs: %Movs% for /l %%f in (0,1, %LimY%) do (echo. !Lin_%% style="color: #448888;">f!) keyboard if " %errorlevel%"=="77" (call : MovX+ " %CurPos%" ) if " %errorlevel%"=="75" (call : MovX- " %CurPos%" ) if " %errorlevel%"=="80" (call : MovY+ " %CurPos%" ) if " %errorlevel%"=="72" (call : MovY- " %CurPos%" ) if " %errorlevel%"=="88" (set EOG=True &Goto : Eof) if " %errorlevel%"=="120" (set EOG=True &Goto : Eof) if " %NXL%"=="True" (Goto : Eof) ::Logica de Movimiento en el Plano ::Coded by :: SmartGenius :: :MovX+ for /f "tokens=1,2 delims=X,Y" %%p in (" %~1" ) do ( if " !NMovX!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovX!"=="% style="color: #448888;">Push%" ( if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if " !NMovX!"=="% style="color: #448888;">Box%" ( if " !NMovXX!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovXX!"=="% style="color: #448888;">Box%" (Goto :Eof) if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= for %%u in (%Pushes%) do (if " !%% style="color: #448888;">u!"==" " (set %%u=%Push%)) :MovX- for /f "tokens=1,2 delims=X,Y" %%p in (" %~1" ) do ( if " !NMovX!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovX!"=="% style="color: #448888;">Push%" ( if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if " !NMovX!"=="% style="color: #448888;">Box%" ( if " !NMovXX!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovXX!"=="% style="color: #448888;">Box%" (Goto :Eof) if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= for %%u in (%Pushes%) do (if " !%% style="color: #448888;">u!"==" " (set %%u=%Push%)) :MovY+ for /f "tokens=1,2 delims=X,Y" %%p in (" %~1" ) do ( if " !NMovY!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovY!"=="% style="color: #448888;">Push%" ( if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if " !NMovY!"=="% style="color: #448888;">Box%" ( if " !NMovYY!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovYY!"=="% style="color: #448888;">Box%" (Goto :Eof) if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= for %%u in (%Pushes%) do (if " !%% style="color: #448888;">u!"==" " (set %%u=%Push%)) :MovY- for /f "tokens=1,2 delims=X,Y" %%p in (" %~1" ) do ( if " !NMovY!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovY!"=="% style="color: #448888;">Push%" ( if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= if " !NMovY!"=="% style="color: #448888;">Box%" ( if " !NMovYY!"=="% style="color: #448888;">Bound%" (Goto :Eof) if " !NMovYY!"=="% style="color: #448888;">Box%" (Goto :Eof) if !% style="color: #448888;">~1!==% style="color: #448888;">Player% set %~1= for %%u in (%Pushes%) do (if " !%% style="color: #448888;">u!"==" " (set %%u=%Push%)) :Clear :Win cls echo Nivel: %%v Movs: !P%%v!) :End msg * Gracias por Jugar PushBox v1 by :: SmartGenius:: ::Niveles del Juego PushBox ::Coordenadas Cartesianas ::Coded by :: SmartGenius :: ::Inicio Nivel 1 :Level1 set Pushes=X5Y2,X6Y2,X7Y2 for %%i in (X2Y1,X3Y1,X4Y1,X5Y1,X6Y1,X7Y1,X8Y1,X2Y2,X8Y2,X2Y3,X6Y3,X7Y3,X8Y3,X9Y3 ) do (set %%i= %Bound%) for %%j in (X1Y4,X2Y4,X3Y4,X9Y4,X1Y5,X5Y5,X7Y5,X9Y5,X1Y6,X5Y6,X9Y6,X1Y7,X5Y7,X6Y7 ) do (set %%j= %Bound%) for %%k in (X7Y7,X8Y7,X9Y7,X1Y8,X2Y8,X3Y8,X4Y8,X5Y8,X6Y8 ) do (set %%k= %Bound%) for %%l in (X3Y2,X3Y3,X4Y3,X5Y3,X5Y4,X6Y4,X7Y4,X8Y4,X2Y5,X3Y5 ) do (set %%l= ) for %%m in (X4Y5,X8Y5,X2Y6,X4Y6,X6Y6,X7Y6,X8Y6,X2Y7,X3Y7,X4Y7 ) do (set %%m= ) :Check1 if " !X5Y2!"=="% style="color: #448888;">Box%" ( if " !X6Y2!"=="% style="color: #448888;">Box%" ( if " !X7Y2!"=="% style="color: #448888;">Box%" set NXL=True)) ::Fin Nivel 1 ::Inicio Nivel 2 :Level2 set Pushes=X3Y5,X3Y6,X3Y7 for %%i in (X3Y1,X4Y1,X5Y1,X6Y1,X3Y2,X6Y2,X7Y2,X8Y2,X3Y3,X8Y3,X2Y4,X3Y4,X4Y4,X6Y4 ) do (set %%i= %Bound%) for %%j in (X8Y4,X9Y4,X2Y5,X4Y5,X6Y5,X9Y5,X2Y6,X7Y6,X9Y6,X2Y7,X9Y7,X2Y8,X3Y8,X4Y8 ) do (set %%j= %Bound%) for %%k in (X5Y8,X6Y8,X7Y8,X8Y8,X9Y8 ) do (set %%k= %Bound%) for %%l in (X5Y2,X4Y3,X6Y3,X7Y3,X5Y4,X7Y4,X5Y5,X7Y5 ) do (set %%l= ) for %%m in (X8Y5,X5Y6,X6Y6,X8Y6,X4Y7,X5Y7,X6Y7,X8Y7 ) do (set %%m= ) :Check2 if " !X3Y5!"=="% style="color: #448888;">Box%" ( if " !X3Y6!"=="% style="color: #448888;">Box%" ( if " !X3Y7!"=="% style="color: #448888;">Box%" set NXL=True)) ::Fin Nivel 2 ::Inicio Nivel 3 :Level3 set Pushes=X3Y6,X4Y6,X3Y7,X4Y7 for %%h in (X3Y4,X5Y5,X8Y5,X7Y6 ) do (set %%h= %Box%) for %%i in (X2Y2,X3Y2,X4Y2,X5Y2,X6Y2,X7Y2,X8Y2,X2Y3,X8Y3,X9Y3,X10Y3,X1Y4,X2Y4,X4Y4 ) do (set %%i= %Bound%) for %%j in (X5Y4,X6Y4,X10Y4,X1Y5,X10Y5,X1Y6,X5Y6,X9Y6,X10Y6,X1Y7,X2Y7,X5Y7,X9Y7 ) do (set %%j= %Bound%) for %%k in (X2Y8,X3Y8,X4Y8,X5Y8,X6Y8,X7Y8,X8Y8,X9Y8 ) do (set %%k= %Bound%) for %%l in (X3Y3,X4Y3,X5Y3,X6Y3,X7Y3,X7Y4,X8Y4,X9Y4,X2Y5,X4Y5 ) do (set %%l= ) for %%m in (X6Y5,X7Y5,X9Y5,X2Y6,X6Y6,X8Y6,X6Y7,X7Y7,X8Y7 ) do (set %%m= ) :Check3 if " !X3Y6!"=="% style="color: #448888;">Box%" ( if " !X3Y7!"=="% style="color: #448888;">Box%" ( if " !X4Y6!"=="% style="color: #448888;">Box%" ( if " !X4Y7!"=="% style="color: #448888;">Box%" set NXL=True))) ::Fin Nivel 3 ::Inicio Nivel 4 :Level4 set Pushes=X7Y3,X7Y4,X7Y5,X7Y6 for %%h in (X5Y3,X6Y3,X6Y4,X5Y5 ) do (set %%h= %Box%) for %%i in (X3Y1,X4Y1,X5Y1,X6Y1,X3Y2,X6Y2,X7Y2,X8Y2,X3Y3,X8Y3,X3Y4,X8Y4 ) do (set %%i= %Bound%) for %%j in (X3Y5,X8Y5,X3Y6,X8Y6,X3Y7,X4Y7,X5Y7,X6Y7,X7Y7,X8Y7,X5Y6 ) do (set %%j= %Bound%) for %%l in (X4Y2,X5Y2,X4Y3,X5Y4,X4Y5,X6Y5,X4Y6,X6Y6 ) do (set %%l= ) :Check4 if " !X7Y3!"=="% style="color: #448888;">Box%" ( if " !X7Y4!"=="% style="color: #448888;">Box%" ( if " !X7Y5!"=="% style="color: #448888;">Box%" ( if " !X7Y6!"=="% style="color: #448888;">Box%" set NXL=True))) ::Inicio Nivel 5 :Level5 set Pushes=X4Y5,X5Y5,X6Y5,X7Y5 for %%h in (X2Y4,X3Y5,X8Y4,X9Y5 ) do (set %%h= %Box%) for %%i in (X1Y2,X2Y2,X3Y2,X4Y2,X7Y2,X8Y2,X9Y2,X10Y2,X11Y2,X0Y3,X1Y3,X4Y3 ) do (set %%i= %Bound%) for %%j in (X7Y3,X11Y3,X0Y4,X4Y4,X5Y4,X6Y4,X7Y4,X11Y4,X0Y5,X11Y5,X0Y6,X1Y6 ) do (set %%j= %Bound%) for %%k in (X6Y6,X10Y6,X11Y6,X1Y7,X2Y7,X3Y7,X4Y7,X5Y7,X6Y7,X7Y7,X8Y7,X9Y7 ) do (set %%k= %Bound%) for %%l in (X2Y3,X3Y3,X8Y3,X9Y3,X10Y3,X1Y4,X3Y4,X9Y4,X10Y4,X1Y5,X2Y5,X8Y5 ) do (set %%l= ) for %%m in (X10Y5,X2Y6,X3Y6,X4Y6,X5Y6,X7Y6,X9Y6 ) do (set %%m= ) :Check5 if " !X4Y5!"=="% style="color: #448888;">Box%" ( if " !X5Y5!"=="% style="color: #448888;">Box%" ( if " !X6Y5!"=="% style="color: #448888;">Box%" ( if " !X7Y5!"=="% style="color: #448888;">Box%" set NXL=True))) ::Fin Nivel 5 ::Fin de Coordenadas :Logo cls :::::::::::::::::::: ::Records by Smart:: :: :: ::Nivel 1: 70 Movs:: ::Nivel 2: 50 Movs:: ::Nivel 3:116 Movs:: ::Nivel 4: 25 Movs:: ::Nivel 5: 63 Movs:: :::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::: ::El Siguiente Codigo se encarga de Crear el ::archivo necesario para recibir entradas desde ::el teclado..... KEYBOARD.EXE ::Creditos a Carlitos ;) :::::::::::::::::::::::::::::::::::::::::::::::: :NoKey @mode con cols=30 lines=20 cls echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo A Continuacion sera creado... echo Archivo Creado Satisfactoriamente... echo Por favor reinicie el Script. :keyboard ( echo e 0000 4D 5A 2E 00 01 00 00 00 02 00 00 10 FF FF F0 FF echo e 0010 FE FF 00 00 00 01 F0 FF 1C 00 00 00 00 00 00 00 echo e 0020 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21 )>keyboard.dat type keyboard.dat |debug >NUL 2 >&1 del /f/q/a "keyboard.exe" >NUL 2 >&1 ren keyboard.dat "keyboard.exe"
El Juego Consta de 5 Niveles con diferente Grado de Dificultad en cuanto a la Resolucion del Puzzle, y pueden agregarse mas Niveles.....siempre y cuando esten bien diseados y cumplan con la logica del juego. Pronto les Traere mas Niveles para Este mismo Juego.... Los Records Para los Niveles Son:
::Records by Smart ::Nivel 1: 70 Movs ::Nivel 2: 50 Movs ::Nivel 3:116 Movs ::Nivel 4: 25 Movs ::Nivel 5: 63 MovsTraten de Hacer su mejor Esfuerzo en resolverlos..... .......de seguro les gustara, acepto comentarios, dudas y sugerencias..... Un Saludo. PD: Quien Dijo que no se podia Jugar en Batch ??....... PD2: El Limite es tu Imaginacion !!!
|
|
|
78
|
Programacin / Scripting / [Batch Game] Buscaminas v 1 - by :: SmartGenius ::
|
en: 16 Enero 2009, 19:47 pm
|
Bueno, tomando como base lo explicado de Graficas y Coordenadas en Batch: http://foro.elhacker.net/scripting/graficos_y_coordenadas_en_batch_by_smartgenius-t241895.0.htmlY lo otro que habian dicho por ahi de que en "Batch no se podia Jugar !!! " ..... Este es un Ejemplo Practico y a la vez divertido de la Aplicacion de las Coordenadas en el Dibujo de Graficas en la Consola del CMD, y el uso de Movimiento para las Mismas. Os traigo el Clasico Juego del Buscaminas en su Version 1, creado totalmente por Mi. Buscaminas v 1 - By SmartGenius @echo off @title Buscaminas @mode con cols=18 lines=13 @::MineSweeper v 1 @::Coded by ::SmartGenius::
if not exist "keyboard.exe" (Goto :NoKey)
:load setlocal enabledelayedexpansion set LimX=9 set LimY=9 set IniX=0 set IniY=0 set MovX=0 set MovY=0
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b= )) for /l %%m in (0,1,9) do (set M%%m=X!random:~-1!Y!random:~-1!) set X0Y0= set Last= set Curpos=X0Y0 Goto :First
:Graphic Call :Clear :First for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d! )) echo. echo. MineSweeper v 1 echo. for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) if "%EOG%"=="True" Goto :End keyboard if "%errorlevel%"=="77" (call :MovX+ "%CurPos%") if "%errorlevel%"=="75" (call :MovX- "%CurPos%") if "%errorlevel%"=="80" (call :MovY+ "%CurPos%") if "%errorlevel%"=="72" (call :MovY- "%CurPos%") if "%errorlevel%"=="13" (call :Check "%CurPos%") if "%errorlevel%"=="88" (msg * Gracias por Jugar Buscaminas v1 by SmartGenius&exit) if "%errorlevel%"=="120" (msg * Gracias por Jugar Buscaminas v1 by SmartGenius&exit) Goto :Graphic
:MovX+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%LimX%" Goto :Eof if !%~1!== set %~1=%Last% set /a MovX=%%p+1 call set Last=%%X!MovX!Y%%q%% set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
:MovX- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%IniX%" Goto :Eof if !%~1!== set %~1=%Last% set /a MovX=%%p-1 call set Last=%%X!MovX!Y%%q%% set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
:MovY+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%LimY%" Goto :Eof if !%~1!== set %~1=%Last% set /a MovY=%%q+1 call set Last=%%X%%pY!MovY!%% set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
:MovY- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%IniY%" Goto :Eof if !%~1!== set %~1=%Last% set /a MovY=%%q-1 call set Last=%%X%%pY!MovY!%% set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
:Check for /l %%h in (0,1,9) do ( if "%~1"=="!M%%h!" ( set %~1= set EOG=True Goto :Eof )) set %~1= Goto :Eof
:End msg * Perdiste ! pause>nul exit
:Clear for /l %%m in (0,1,%LimY%) do (set Lin_%%m=) Goto :Eof
:NoKey cls echo. echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo encuentra. echo. echo A Continuacion sera creado... call :keyboard echo. echo Archivo Creado Satisfactoriamente... echo Por favor reinicie el Script. echo. pause exit
:keyboard ( echo n keyboard.dat echo e 0000 4D 5A 2E 00 01 00 00 00 02 00 00 10 FF FF F0 FF echo e 0010 FE FF 00 00 00 01 F0 FF 1C 00 00 00 00 00 00 00 echo e 0020 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21 echo rcx echo 002E echo w0 echo q echo. )>keyboard.dat type keyboard.dat|debug>NUL 2>&1 del /f/q/a "keyboard.exe">NUL 2>&1 ren keyboard.dat "keyboard.exe" Goto :Eof Mueven su figurita con las flechas de direccion (arriba, abajo, izquierda, derecha...respectivamente) y para descubrir una casilla presionan Enter. Para Salir del Juego presionan la tecla XLa primera vez que lo ejecuten se les creara el Archivo KEYBOARD.EXE que es el encargado de recibir cada una de las ordenes que le damos mediente el teclado... Espero que les guste, y como les digo....solo la imaginacion es el Limite !!!!! Un Saludo
|
|
|
79
|
Programacin / Scripting / Re: Graficos y Coordenadas en Batch - by SmartGenius
|
en: 16 Enero 2009, 19:45 pm
|
Para la parte de los Movimientos en los graficos, puede tambien usarse un movimiento diagonal combinando la llamada a dos etiquetas de Movimiento XY... Ej: Mover el punto en el Plano, usando el teclado numerico.... 1 = Diagonal Abajo Izquierda 2 = Abajo 3 = Diagonal Abajo Derecha 4 = Izquierda 5 = No Mover 6 = Derecha 7 = Diagonal Arriba Izquierda 8 = Arriba 9 = Diagonal Arriba DerechaLo cual puede ser usado en el Desarrollo de Juegos (Basicos claro esta) en Batch !!!... @echo off @mode con cols=20 lines=18 @::Graphical Maths @::by Smart
if not exist "keyboard.exe" (Goto :NoKey)
:load setlocal enabledelayedexpansion for /f "tokens=2" %%x in ('mode ^|find "Col"') do (set /a LimX=%%x-3) for /f "tokens=2" %%y in ('mode ^|find "nea"') do (set /a LimY=%%y-3) set IniX=0 set IniY=0 set MovX=0 set MovY=0
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b= )) set X0Y0= set Curpos=X0Y0 Goto :First
:Graphic Call :Clear :First for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d! )) echo. for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) keyboard if "%errorlevel%"=="49" (call :Diag4 "%CurPos%") if "%errorlevel%"=="50" (call :MovY+ "%CurPos%") if "%errorlevel%"=="51" (call :Diag1 "%CurPos%") if "%errorlevel%"=="52" (call :MovX- "%CurPos%") if "%errorlevel%"=="53" (Goto :Graphic) if "%errorlevel%"=="54" (call :MovX+ "%CurPos%") if "%errorlevel%"=="55" (call :Diag2 "%CurPos%") if "%errorlevel%"=="56" (call :MovY- "%CurPos%") if "%errorlevel%"=="57" (call :Diag3 "%CurPos%") if "%errorlevel%"=="88" (exit) if "%errorlevel%"=="120" (exit) Goto :Graphic
::Movimiento Lateral a la Derecha :MovX+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%LimX%" Goto :Eof set %~1= set /a MovX=%%p+1 set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
::Movimiento Lateral a la Izquierda :MovX- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%IniX%" Goto :Eof set %~1= set /a MovX=%%p-1 set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
::Movimiento Vertical hacia Abajo :MovY+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%LimY%" Goto :Eof set %~1= set /a MovY=%%q+1 set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
::Movimiento Vertical hacia Arriba :MovY- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%IniY%" Goto :Eof set %~1= set /a MovY=%%q-1 set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
::Movimiento Diagonal1 :Diag1 Call :MovX+ "%CurPos%" Call :MovY+ "%CurPos%" Goto :Eof
::Movimiento Diagonal2 :Diag2 Call :MovX- "%CurPos%" Call :MovY- "%CurPos%" Goto :Eof
::Movimiento Diagonal3 :Diag3 Call :MovX+ "%CurPos%" Call :MovY- "%CurPos%" Goto :Eof
::Movimiento Diagonal4 :Diag4 Call :MovX- "%CurPos%" Call :MovY+ "%CurPos%" Goto :Eof
:Clear for /l %%m in (0,1,15) do (set Lin_%%m=) Goto :Eof
:NoKey cls echo. echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo encuentra. echo. echo A Continuacion sera creado... call :keyboard echo. echo Archivo Creado Satisfactoriamente... echo Por favor reinicie el Script. echo. pause exit
:keyboard ( echo n keyboard.dat echo e 0000 4D 5A 2E 00 01 00 00 00 02 00 00 10 FF FF F0 FF echo e 0010 FE FF 00 00 00 01 F0 FF 1C 00 00 00 00 00 00 00 echo e 0020 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21 echo rcx echo 002E echo w0 echo q echo. )>keyboard.dat type keyboard.dat|debug>NUL 2>&1 del /f/q/a "keyboard.exe">NUL 2>&1 ren keyboard.dat "keyboard.exe" Goto :Eof Y para crear efectos de animaciones, puede hacerse un bucle de coordenadas, en el cual se van definiendo de a una por una y crean un efecto de animacion parecido a los antes descritos en mis codigos... un Saludo.
|
|
|
80
|
Programacin / Scripting / Graficos y Coordenadas en Batch - by SmartGenius
|
en: 16 Enero 2009, 19:44 pm
|
Para este tema tomaremos como base la explicacion del Plano Cartesiano y el significado de Coordenadas: http://es.wikipedia.org/wiki/Coordenadas_cartesianasLuego lo que quiero llegar a representar con esto es el Cuadrante IV del Sistema de Coordenadas Plano, en el cual se especifican pares de coordenadas para los ejes X & Y de la forma X=0 y Y=0. (X0Y0) Como tomamos como base el cuadrante IV las coordenadas que demos seran dibujadas de la siguiente forma: Ej: X1Y0,X5Y6
0 1 2 3 4 5 6 7 8 9 10 .----------------------------------------------> 1 | X 2 | 3 | 4 | 5 | 6 | X 7 | \/Ahora, el objetivo es que mediante coordenadas podamos realizar dibujos en la consola, un script en el cual se definen las dimensiones de los dos ejes y luego se pasan las coordenadas que tomaran valor, para formar cualquier figura. Graphical: @echo off @::Graphical Maths @::Coded by SmartGenius
if ["%1"]==[""] Echo Parametros Insuficientes!&Goto :Eof if ["%2"]==[""] Echo Parametros Insuficientes!&Goto :Eof if ["%~3"]==[""] Echo No ha Establecido Coordenadas!&Goto :Eof
:load setlocal enabledelayedexpansion set /a LimX=%1 set /a LimY=%2
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b=)) for %%c in (%~3) do (set %%c=) Goto :Graphic
:Graphic for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d!)) echo. for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) endlocal Goto :Eof La forma de llamar al Script es pasandole tres parametros correspondientes a: %1 = Longitud del Eje X %2 = Longitud del Eje Y "%3" = Pares de Coordenadas, separadas por comas. (todo entre comillas)Ej: (todo el parametro de coordenadas en una sola linea por favor ) @echo off call Graphics 22 6 "x1y1,x2y1,x3y1,x5y1,x6y1,x8y1,x9y1,x11y1,x12y1,x13y1,x15y1,x16y1,x17y1,x19y1,x20y1,x21y1, x1y2,x5y2,x7y2,x9y2,x11y2,x13y2,x15y2,x17y2,x20y2,x1y3,x2y3,x3y3,x5y3,x9y3,x11y3,x12y3,x13y3,x15y3,x16y3, x20y3,x3y4,x5y4,x9y4,x11y4,x13y4,x15y4,x17y4,x20y4,x1y5,x2y5,x3y5,x5y5,x9y5,x11y5,x13y5,x15y5,x17y5,x20y5" pause exit Con eso llamamos al Script que nos crea un Plano cuyo EjeX sera de 22, el EjeY sera de 6 y Cuyas coordenadas dan como Resultado: Esto para cuando se trabaja desde la consola, pero tambien desde un codigo .BAT externo puede adaptarse al tamao del BUFER actual del CMD, el cual es modificado mediante el comando MODE de la forma MODE CON COLS=XX LINES=XX @echo off @::Graphical Maths @::Coded by Smart
if ["%1"]==[""] Echo Parametros Insuficientes!&Goto :Eof if ["%2"]==[""] Echo Parametros Insuficientes!&Goto :Eof if ["%~3"]==[""] Echo No ha Establecido Coordenadas!&Goto :Eof
:load setlocal enabledelayedexpansion for /f "tokens=2" %%x in ('mode ^|find "Col"') do (set /a LimX=%%x-3) for /f "tokens=2" %%y in ('mode ^|find "nea"') do (set /a LimY=%%y-3)
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b= )) for %%c in (%~3) do (set %%c=) Goto :Graphic
:Graphic for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d! )) echo. for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) pause >nul endlocal Goto :Eof Las primeras lienas del FOR se encargaran de leer el tamao de BUFER definido mediante MODE, y adaptar el plano a estas longitudes. Todo esto tiene gran aplicacion al momento de generar graficos en la Consola del CMD, sin estar definiendo gran cantidad de variables como lo hacia en codigo anteriores mios, sino que las variables se definen dinamicamente y no necesitan tantas lineas de Codigo. Esto tambien puede ampliarse aun mas, y que el grafico no sea estatico sino que tenga movimeinto, todo esto bajo el limite de su imaginacion. Ej: @echo off @mode con cols=20 lines=18 @::Graphical Maths @::by Smart
if not exist "keyboard.exe" (Goto :NoKey)
:load setlocal enabledelayedexpansion for /f "tokens=2" %%x in ('mode ^|find "Col"') do (set /a LimX=%%x-3) for /f "tokens=2" %%y in ('mode ^|find "nea"') do (set /a LimY=%%y-3) set IniX=0 set IniY=0 set MovX=0 set MovY=0
:init for /l %%a in (0,1,%LimX%) do ( for /l %%b in (0,1,%LimY%) do ( set X%%aY%%b= )) set X0Y0= set Curpos=X0Y0 Goto :First
:Graphic Call :Clear :First for /l %%d in (0,1,%LimY%) do ( for /l %%e in (0,1,%LimX%) do ( set Lin_%%d=!Lin_%%d!!X%%eY%%d! )) echo. for /l %%f in (0,1,%LimY%) do (echo. !Lin_%%f!) keyboard if "%errorlevel%"=="77" (call :MovX+ "%CurPos%") if "%errorlevel%"=="75" (call :MovX- "%CurPos%") if "%errorlevel%"=="80" (call :MovY+ "%CurPos%") if "%errorlevel%"=="72" (call :MovY- "%CurPos%") if "%errorlevel%"=="88" (pause&exit) if "%errorlevel%"=="120" (pause&exit) Goto :Graphic
::Movimiento Lateral a la Derecha :MovX+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%LimX%" Goto :Eof set %~1= set /a MovX=%%p+1 set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
::Movimiento Lateral a la Izquierda :MovX- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%p"=="%IniX%" Goto :Eof set %~1= set /a MovX=%%p-1 set X!MovX!Y%%q= set CurPos=X!MovX!Y%%q ) Goto :Eof
::Movimiento Vertical hacia Abajo :MovY+ for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%LimY%" Goto :Eof set %~1= set /a MovY=%%q+1 set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
::Movimiento Vertical hacia Arriba :MovY- for /f "tokens=1,2 delims=X,Y" %%p in ("%~1") do ( if "%%q"=="%IniY%" Goto :Eof set %~1= set /a MovY=%%q-1 set X%%pY!MovY!= set CurPos=X%%pY!MovY! ) Goto :Eof
:Clear for /l %%m in (0,1,%LimY%) do (set Lin_%%m=) Goto :Eof
:NoKey cls echo. echo Uno de los archivos necesarios para el echo funcionamiento de este Script no se echo encuentra. echo. echo A Continuacion sera creado... call :keyboard echo. echo Archivo Creado Satisfactoriamente... echo Por favor reinicie el Script. echo. pause exit
:keyboard ( echo n keyboard.dat echo e 0000 4D 5A 2E 00 01 00 00 00 02 00 00 10 FF FF F0 FF echo e 0010 FE FF 00 00 00 01 F0 FF 1C 00 00 00 00 00 00 00 echo e 0020 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21 echo rcx echo 002E echo w0 echo q echo. )>keyboard.dat type keyboard.dat|debug>NUL 2>&1 del /f/q/a "keyboard.exe">NUL 2>&1 ren keyboard.dat "keyboard.exe" Goto :Eof Espero que les sea muy util.... ... Saludos.
|
|
|
|
|
|
|