#1 09 Aug 2010 06:56

SmartGenius
Member
Registered: 11 Dec 2008
Posts: 26

[Batch Game] Tetris v 1.3

[Batch Game] Tetris v 1.3 - by SmartGenius

tetrissplash.png

Download: http://smart.code-makers.net/BatchGames … Genius.zip

The classic tetris game, coded in batch, by me. Try the game, use keys S (Move down) A( Move left) D (Move rigth) R (Rotate) X (exit game).

@Echo off
@title Tetris v1.3
@mode con cols=28 lines=24
Setlocal enabledelayedexpansion enableextensions

:: Batch Game - Tetris v1.3
:: Coded by SmartGenius
:: SmartGenius, Corp. 2010
:: Greets to Carlos ;) (for KBD and bug fixes)

Set "Game=%0"

Kbd.exe 1 2>Nul
If "%Errorlevel%"=="9009" (Echo. Kbd command not found&Pause&Exit /b)

Call :Logo

:Menu
Cls
Echo.
Echo.
Echo. Tetris v1.3 by SmartGenius
Echo. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Echo. ÚÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿
Echo. ³1.³ ³Play TETRIS ³
Echo. ÀÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
Echo. ÚÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿
Echo. ³2.³ ³How to Play ³
Echo. ÀÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
Echo. ÚÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄ¿
Echo. ³3.³ ³Exit Game   ³
Echo. ÀÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
Echo.
:MenuIn
Kbd.exe 2
If "%errorlevel%"=="49" (Goto :Load)
If "%errorlevel%"=="50" (Goto :Help)
If "%errorlevel%"=="51" (Goto :End)
Goto :MenuIn

:Load
Set /a "LimX=18","LimY=16","TBound=1","LBound=0","Turn=1","Points=0"
Set /a "RBound=%LimX%","BBound=%LimY%"

:Init
For /l %%a in (0,1,%LimX%) do (
For /l %%b in (0,1,%LimY%) do (
Set "X%%aY%%b= "))
Set "Bound=Û"
Set "Bound2=²"
Set /a "NoPress=0,Pressed=0,Over=0"

:Main
Set /a "L=(%Random% %% 7)+1"
Call :Figure%L%
Call :Graphic
If !Over! Equ 1 Goto :Menu
Goto :Main

:Graphic
Call :Clear
Call :CheckL2
If "%New_F%"=="True" (
Call :Solid
Set "New_F=False"
Goto :Eof
)
Call :Clear
Cls
Echo.
Echo. Tetris v1.3 by SmartGenius
Echo.
Echo.   Points:%Points%
Echo.   ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
For /l %%f in (0,1,%LimY%) do (Echo.   º!Lin_%%f!º)
Echo.   ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
:Move
Kbd.exe 1
Set /a "K=!ErrorLevel!"
If !k! Equ 0 (
  Set /a "NoPress+=1"
  If !NoPress! Equ 3 (
    Set /a "NoPress=0"
    Call :Down
  )
) Else Set /a "Pressed+=1"
If !k! Equ 80 (Call :Down)
If !k! Equ 75 (Call :Left)
If !k! Equ 77 (Call :Rigth)
If !k! Equ 32 (Call :Rotate)
If !k! Equ 120 (Set /a "Over=1" & Goto :Eof)
If !k! Equ 88 (Set /a "Over=1" & Goto :Eof)
If !k! Equ 99 (Call :MovCR)
If !k! Equ 67 (Call :MovCR)
If !Pressed! Equ 3 (
  Set /a "Pressed=0"
  Call :Down
)
If !Over! Equ 1 Goto :Lost
Goto :Graphic

::::::::::::::::::::::::::::::::::::::::
:Solid
For %%a in (%Table%) do (Set "%%a=%Bound2%")
Goto :Eof

:Rotate
Set "TmpTB="
If "%XToken%"=="-7" (Set "XToken=-6")
If "%XToken%"=="11" (Set "XToken=10")
If "%YToken%"=="15" (Set "XToken=14")
Set /a "NextRotate=(%RotateLevel% %% 4)+1"
Set "TmpTable=!Figure%CurFig%_Pos%NextRotate%!
For %%R in (%TmpTable%) do (
Call :MovR "%YToken%" "%XToken%" "%%R" "Val"
Call Set "TmpTB=!TmpTB!,!Val!"
)
For %%c in (%TmpTB:~1%) do (
If "!%%c!"=="%Bound2%" (
For %%b in (%Table%) do (Set "%%b=%Bound%")
Goto :Eof
))
For %%a in (%Table%) do (Set "%%a= ")
Set "Table=%TmpTB:~1%"
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "RotateLevel+=1"
Goto :Eof

:MovR
For /f "tokens=1,2 delims=X,Y" %%p in ("%~3") do (
Set /a MovY=%%q+%~1
Set /a MovX=%%p+%~2
Set "%~4=X!MovX!Y!MovY!"
Set "%~3= ")
Goto :Eof

:::::::::::::::::::::::::::::::::::::::::::
:Down
Set "TmpTB="
Set "TmpTable=%Table%"
For %%a in (%TmpTable%) do (
Echo.!TmpTable!|Find "Y%BBound%">nul
If !Errorlevel! EQU 0 (Set "New_F=True"&Goto :Eof)
Call :MovYR "1" "%%a" "Val"
Call Set "TmpTB=!TmpTB!,!Val!"
)
For %%c in (%TmpTB:~1%) do (
If "!%%c!"=="%Bound2%" (
Set "New_F=True"
For %%b in (%Table%) do (Set "%%b=%Bound%")
Goto :Eof
))
Set "Table=%TmpTB:~1%"
For %%d in (%Table%) do (Set "%%d=%Bound%")
Set /a "YToken+=1"
Goto :Eof

:MovYR
For /f "tokens=1,2 delims=X,Y" %%p in ("%~2") do (
Set /a MovY=%%q+%~1
Set "%~3=X%%pY!MovY!"
Set "%~2= ")
Goto :Eof

:MovCR
Cls
Echo.
Echo.
Call :L2 "Goto :Eof"
Echo.
For /f "tokens=2 skip=3" %%c in ('find "::_0" %Game%') do (
Set "Tmp_Var=%%c"
Call :Key.A Tmp_Var
Echo. !Tmp_Var!
)
Pause >nul
Goto :Eof
::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::::::
:Rigth
Set "TmpTB="
Set "TmpTable=%Table%"
For %%a in (%TmpTable%) do (
Echo.!TmpTable!|Find "X%RBound%">nul
If !Errorlevel! EQU 0 (Goto :Eof)
Call :MovXR "+1" "%%a" "Val"
Call Set "TmpTB=!TmpTB!,!Val!"
)
For %%c in (%TmpTB:~1%) do (
If "!%%c!"=="%Bound2%" (
For %%b in (%Table%) do (Set "%%b=%Bound%")
Goto :Eof
))
Set "Table=%TmpTB:~1%"
For %%d in (%Table%) do (Set "%%d=%Bound%")
Set /a "XToken+=1"
Goto :Eof

:Left
Set "TmpTB="
Set "TmpTable=%Table%"
For %%a in (%TmpTable%) do (
Echo.!TmpTable!|Find "X%LBound%">nul
If !Errorlevel! EQU 0 (Goto :Eof)
Call :MovXR "-1" "%%a" "Val"
Call Set "TmpTB=!TmpTB!,!Val!"
)
For %%c in (%TmpTB:~1%) do (
If "!%%c!"=="%Bound2%" (
For %%b in (%Table%) do (Set "%%b=%Bound%")
Goto :Eof
))
Set "Table=%TmpTB:~1%"
For %%d in (%Table%) do (Set "%%d=%Bound%")
Set /a "XToken-=1"
Goto :Eof

:MovXR
For /f "tokens=1,2 delims=X,Y" %%p in ("%~2") do (
Set /a MovX=%%p%~1
Set "%~3=X!MovX!Y%%q"
Set "%~2= ")
Goto :Eof

::::::::::::::::::::::::::::::::::::::::
:CheckL2
Echo.%Lin_1%|Find "%Bound2%">nul
If !Errorlevel! EQU 0 (Goto :Lost)

Echo.!Lin_%LimY%!|Find " ">nul
If !Errorlevel! EQU 0 (Goto :Eof)

Call :Solid

For /l %%x in (0,1,%LimX%) do (
For /l %%y in (%LimY%,-1,1) do (
Set /a "UpLine=%%y-1"
Call Set "X%%xY%%y=%%X%%xY!UpLine!%%"
))
Set /a "Points+=100"
For /l %%d in (0,1,%LimX%) do (Set "X%%dY0= ")
Call :Clear
Goto :CheckL2
:::::::::::::::::::::::::::::::::::::::::

:Key.A
If not defined %1 Goto:Eof
Set "c="
Set "d=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz =/\()[]{}_-.:,;* @#"
:Key.B
Set "chr=!%1:~,1!"
For /l %%l in (0 1 80) do if "!chr!" equ "!d:~%%l,1!" (
  set /a "x=%%l^5"
  call set "c=!c!%%d:~!x!,1%%"
)
Set "%1=!%1:~1!"
If defined %1 goto:Key.B
Set "%1=!c!"
Goto :Eof
:::::::::::::::::::::::::::::::::::::::::

:Clear
For /l %%m in (0,1,%LimY%) do (Set Lin_%%m=)
For /l %%d in (0,1,%LimY%) do (
For /l %%e in (0,1,%LimX%) do (
Set Lin_%%d=!Lin_%%d!!X%%eY%%d!))
Goto :Eof

:Lost
Cls
Echo.
Echo. Tetris v 1.3 by SmartGenius
Echo.
Echo.     Points:%Points%
Echo.        Perdiste !
Goto :End

:Win
Cls
Echo.
Echo. Tetris v 1.3 by SmartGenius
Echo.
Echo.     Points:%Points%
Echo.      Has Ganado !
Goto :End

:End
Echo.     Thanks for Play
Echo. Tetris v1.2 by SmartGenius
Endlocal
Ping -n 3 localhost >nul
Goto :Menu

::::::::::::::::::::::::::::::::::::::::::
:Figure1
Set Figure1_Pos1=X6Y2,X6Y1,X7Y1,X7Y0
Set Figure1_Pos2=X7Y1,X8Y1,X6Y0,X7Y0
Set Figure1_Pos3=X6Y2,X6Y1,X7Y1,X7Y0
Set Figure1_Pos4=X7Y1,X8Y1,X6Y0,X7Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure1_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=1","RotateLevel=%R%"
Goto :Eof

:Figure2
Set Figure2_Pos1=X7Y2,X6Y1,X7Y1,X6Y0
Set Figure2_Pos2=X6Y1,X7Y1,X7Y0,X8Y0
Set Figure2_Pos3=X7Y2,X6Y1,X7Y1,X6Y0
Set Figure2_Pos4=X6Y1,X7Y1,X7Y0,X8Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure2_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=2","RotateLevel=%R%"
Goto :Eof

:Figure3
Set Figure3_Pos1=X7Y1,X8Y1,X7Y0,X8Y0
Set Figure3_Pos2=X7Y1,X8Y1,X7Y0,X8Y0
Set Figure3_Pos3=X7Y1,X8Y1,X7Y0,X8Y0
Set Figure3_Pos4=X7Y1,X8Y1,X7Y0,X8Y0
Set /a "R=(%Random% %% 4)+1"
Set "Table=!Figure3_Pos%R%!"
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=3","RotateLevel=%R%"
Goto :Eof

:Figure4
Set Figure4_Pos1=X6Y1,X7Y1,X8Y1
Set Figure4_Pos2=X7Y2,X7Y1,X7Y0
Set Figure4_Pos3=X6Y1,X7Y1,X8Y1
Set Figure4_Pos4=X7Y2,X7Y1,X7Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure4_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=4","RotateLevel=%R%"
Goto :Eof

:Figure5
Set Figure5_Pos1=X6Y1,X7Y1,X8Y1,X7Y0
Set Figure5_Pos2=X7Y2,X7Y1,X8Y1,X7Y0
Set Figure5_Pos3=X7Y1,X6Y0,X7Y0,X8Y0
Set Figure5_Pos4=X8Y2,X7Y1,X8Y1,X8Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure5_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=5","RotateLevel=%R%"
Goto :Eof

:Figure6
Set Figure6_Pos1=X6Y0,X7Y0,X8Y0,X6Y1
Set Figure6_Pos2=X7Y0,X8Y2,X8Y1,X8Y0
Set Figure6_Pos3=X6Y1,X7Y1,X8Y1,X8Y0
Set Figure6_Pos4=X6Y2,X7Y2,X6Y1,X6Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure6_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=6","RotateLevel=%R%"
title Fig:6 Pos:%R%
Goto :Eof

:Figure7
Set Figure7_Pos1=X8Y1,X6Y0,X7Y0,X8Y0
Set Figure7_Pos2=X7Y2,X8Y2,X8Y1,X8Y0
Set Figure7_Pos3=X6Y1,X7Y1,X8Y1,X6Y0
Set Figure7_Pos4=X6Y2,X6Y1,X6Y0,X7Y0
Set /a "R=(%Random% %% 4)+1"
Set Table=!Figure7_Pos%R%!
For %%b in (%Table%) do (Set "%%b=%Bound%")
Set /a "XToken=0","YToken=0","CurFig=7","RotateLevel=%R%"
Goto :Eof

::_0 xx9tYjYxWvxPrXmoLjqfzpxxx
::_0 xxxxxXhXxLBINRPFGBaxxxxxx
::_0 xxxxxxxxxxxxxxxxxxxxxxxxx
::_0 xxxxx8jYfZXojYxOtxJvxxxxx
::_0 EjXzofizgxLfmgimfjqYx9GVJ
::_0 xxxJvx8XmgfqlxNxGtyjxRxxx
::_0 xxxxxxxxxxxxxxxxxxxxxxxxx
::_0 xxxLmjjopxotx9Xmgtpxxxxxx
::_0 xPrXmoLjqfzpx9tms-x7545xx

:Help
Cls
Echo.
Call :L2 "Goto :Eof"
Echo.
Echo. How to Play Batch Tetris ?
Echo.
Echo. Use arrow keys, space and X
Echo.
Echo. Left = Move Shape Left
Echo. Down = Move Shape Down
Echo. Right = Move Shape Rigth
Echo. Space = Rotate Shape
Echo. X = Back to Menu Game
Echo.
Echo. 
Pause >nul
Goto :Menu

:Logo
Cls
Color 0b
Echo.
Echo. °°°°°°°°°°°°°°°°°°°°°°°°°°
Echo. °°°°°°°°°°°°°°°°°°°°°°°°°°
:L2
Echo. °°ÛÛÛ°ÛÛÛ°ÛÛÛ°ÛÛ°°Û°°ÛÛ°°°
Echo. °°°Û°°Û°°°°Û°°Û°Û°Û°Û°°°°°
Echo. °°°Û°°ÛÛÛ°°Û°°ÛÛ°°Û°°Û°°°°
Echo. °°°Û°°Û°°°°Û°°Û°Û°Û°°°Û°°°
Echo. °°°Û°°ÛÛÛ°°Û°°Û°Û°Û°ÛÛ°°°°
%~1
Echo. °°°°°°°°°°°°°°°°°°°°°°°°°°
Echo. °°±°°°°°°°°°²°°°°°°°°°°±°°
Echo. °°±°²°°°²²°°²²°°°²²²°°°±°°
Echo. °°±°²²°°°²°°²°°°°°°°°°°±°°
Echo. °°±°°²°°°²°°°°°°²²°°°°°±°°
Echo. °°±°°°°°°°°°°°°°°²²°°°°±°°
Echo. °°±°°°°°°°°²°°°°°°°°°°°±°°
Echo. °°±²°°°°°°°²²²°°°°°°°°°±°°
Echo. °°±²°°²²°°°°°°°²°°°°°°²±°°
Echo. °°±²°°²²°°°°°°²²²°°°²²²±°°
Echo. °°±±±±±±±±±±±±±±±±±±±±±±°°
Echo. °°°°°°°°°°°°°°°°°°°°°°°°°°
Echo. °°°°°: SmartGenius :°°°°°°
Echo. °°°°°  Corp.  2010  °°°°°°
Echo. °°°°°°°°°°°°°°°°°°°°°°°°°°
Ping -n 3 0.0.0.0 >nul
Goto :Eof

Hope you like it. Comments and suggestions are welcome.

Greets !

Last edited by SmartGenius (12 Aug 2010 22:45)

Offline

#2 12 Aug 2010 22:45

SmartGenius
Member
Registered: 11 Dec 2008
Posts: 26

Re: [Batch Game] Tetris v 1.3

Tetris Batch Game updated, uses KBD instead of CHOICE, fixed some bugs, shapes falls by default. Re-download and try the new version of the game v 1.3

http://smart.code-makers.net/BatchGames … Genius.zip

Greets to all wink

Last edited by SmartGenius (13 Aug 2010 04:31)

Offline

#3 03 Jan 2018 15:16

Sirius B / FireDOS
New Member
Registered: 03 Jan 2018
Posts: 1

Re: [Batch Game] Tetris v 1.3

Hi dude i wonder if my program codded full in batch can use your tetris in batch please. Cuz in the update we want to do, we want to put games beacauses olders updates was just alphas, and we want to go to beta. Please reply as soon as possible.

Offline

#4 03 Jan 2018 18:17

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 171

Re: [Batch Game] Tetris v 1.3

Sirius B / FireDOS wrote:

Hi dude i wonder if my program codded full in batch can use your tetris in batch please. Cuz in the update we want to do, we want to put games beacauses olders updates was just alphas, and we want to go to beta. Please reply as soon as possible.

You realize that he hasn't logged in since 2014, right? You're not going to get a response.

Offline

Board footer

Powered by FluxBB