GraphicsWindow.Height = 580
GraphicsWindow.Width = 700
GraphicsWindow.Show()
szerokosc=10
wysokosc=20
bok=30
SetupCanvas()
For i=1 To szerokosc
For j=1 To wysokosc
GraphicsWindow.DrawRectangle((i-1)*bok, (j-1)*bok,bok,bok)
EndFor
EndFor
punkty=0
nowy_ksztalt()
For z=1 to szerokosc
granica[z] = GraphicsWindow.Height
Endfor
Sub nowy_ksztalt
x=0
y=0
ksztalt=0
ksztalt_szer=math.GetRandomNumber(3)
ksztalt_wys=Math.GetRandomNumber(3)
GraphicsWindow.BrushColor=GraphicsWindow.GetRandomColor()
ksztalt=Shapes.AddRectangle(ksztalt_szer*bok,ksztalt_wys*bok)
punkty=punkty+1
PokazPunkty()
GraphicsWindow.Title="Small Basic Tetris"
EndSub
Timer.Interval=200
Timer.Tick=rusz_ksztalt
Sub rusz_ksztalt
Shapes.Move(ksztalt,x,y)
y=y+bok
zat_ruchu()
EndSub
Sub zat_ruchu
For z=1 To szerokosc
For q=1 to ksztalt_szer
If y+(ksztalt_wys*bok)>granica[z] And (x/bok)+q=z Then
For w=1 To ksztalt_szer
granica [(x/bok)+w]=y-bok
EndFor
czy_nowy()
EndIf
EndFor
EndFor
EndSub
Sub czy_nowy
For b=1 To szerokosc
If granica[b] <=0 Then
EndIf
EndFor
nowy_ksztalt()
EndSub
GraphicsWindow.KeyDown = sterowanie
Sub sterowanie
If GraphicsWindow.LastKey = "Left" Then
Shapes.Move(ksztalt,x,y)
x = x - bok
EndIf
If GraphicsWindow.LastKey = "Right" Then
Shapes.Move(ksztalt,x,y)
x = x + bok
EndIf
EndSub
Sub SetupCanvas
GraphicsWindow.PenWidth = 6
GraphicsWindow.PenColor = "Black"
GraphicsWindow.DrawLine(XOFFSET, YOFFSET, XOFFSET, YOFFSET + wysokosc*bok)
GraphicsWindow.DrawLine(XOFFSET + szerokosc*bok, YOFFSET, XOFFSET + szerokosc*bok, YOFFSET + wysokosc*bok)
GraphicsWindow.DrawLine(XOFFSET, YOFFSET + wysokosc*bok, XOFFSET + szerokosc*bok, YOFFSET + wysokosc*bok)
GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "Blue"
x = 350
y = 100
GraphicsWindow.FillRectangle(x - 20, y + 190, 310, 170)
GraphicsWindow.DrawRectangle(x - 20, y + 190, 310, 170)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontItalic = "False"
GraphicsWindow.FontName = "Tahoma"
GraphicsWindow.FontSize = 16
GraphicsWindow.DrawText(350, 350, "Sterowanie:")
GraphicsWindow.DrawText(350, 390, "Strzałka w lewo = Ruch w lewo")
GraphicsWindow.DrawText(350, 370, "Strzałka w prawo = Ruch w prawo")
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontName = "Tahoma"
GraphicsWindow.FontItalic = "True"
GraphicsWindow.FontSize = 36
GraphicsWindow.DrawText(320, 100, "Small Basic Tetris")
GraphicsWindow.DrawText(320, 200, "Punkty:")
PokazPunkty()
EndSub
XOFFSET = 40
YOFFSET = 40
Sub PokazPunkty
GraphicsWindow.PenWidth = 6
GraphicsWindow.BrushColor = "Blue"
GraphicsWindow.FillRectangle(500, 200, 100, 50)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawRectangle(500, 200, 100, 50)
GraphicsWindow.FontItalic = "False"
GraphicsWindow.FontSize = 32
GraphicsWindow.FontName = "Impact"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(515, 205, Text.Append(Text.GetSubText( "00000000", 0, 8 - Text.GetLength( punkty ) ), punkty))
EndSub