GraphicsWindow.KeyDown = Klawisze szerokosc = 10 wysokosc = 20 bok = 30 GraphicsWindow.Width = szerokosc*bok GraphicsWindow.Height = wysokosc*bok 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_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 GraphicsWindow.Title = "Masz juz " + punkty + " punktow!" Timer.Interval = 200 Timer.Tick = rusz_ksztalt EndSub 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 k = granica[x+w] granica[x+w] = k - ksztalt_wys*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 Sub Klawisze If GraphicsWindow.LastKey = "Left" Then porusz = -1 'Sprawdz() 'If zly = 0 Then x = x + porusz*bok 'EndIf rusz_ksztalt() EndIf If GraphicsWindow.LastKey = "Right" Then porusz = 1 'Sprawdz() 'If zly = 0 Then x = x + porusz*bok 'EndIf rusz_ksztalt() EndIf If GraphicsWindow.LastKey = "Down" Then Timer.Interval = 0 EndIf EndSub Sub Sprawdz ' in: ypos, xpos, h, moveDirection ret: invalidMove = 1 or -1 or 2 if move is invalid, otherwise 0 i = 0 zly = 0 While i < ksztalt v = ksztalt 'x/y is the box offset within the shape. pozx = Math.Floor(v/10) pozy = Math.Remainder(v, 10) If (x + pozx + porusz) < 0 Then invalidMove = -1 i = ksztalt ' force getting out of the loop EndIf If (x + pozx + porusz) >= szerokosc*bok Then invalidMove = 1 i = ksztalt ' force getting out of the loop EndIf If Array.GetValue("c", (x + pozx + porusz) + (y + pozy) * szerokosc*bok) <> "." Then invalidMove = 2 i = ksztalt ' force getting out of the loop EndIf i = i + 1 EndWhile EndSub