Facebook
From Chartreuse Parrot, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 190
  1. GraphicsWindow.KeyDown = Klawisze
  2.  
  3. szerokosc = 10
  4. wysokosc = 20
  5. bok = 30
  6. GraphicsWindow.Width = szerokosc*bok
  7. GraphicsWindow.Height = wysokosc*bok
  8. For i = 1 To szerokosc
  9.   For j = 1 To wysokosc
  10.     GraphicsWindow.DrawRectangle((i-1)*bok, (j-1)*bok, bok, bok)
  11.   EndFor
  12. EndFor
  13.  
  14. punkty = 0
  15. nowy_ksztalt()
  16.  
  17. For z = 1 To szerokosc
  18.   granica[z] = GraphicsWindow.Height
  19. EndFor
  20.  
  21. Sub nowy_ksztalt
  22.   x = 0
  23.   y = 0
  24.   ksztalt_szer = Math.GetRandomNumber(3)
  25.   ksztalt_wys = Math.GetRandomNumber(3)
  26.   GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
  27.   ksztalt = Shapes.AddRectangle(ksztalt_szer*bok, ksztalt_wys*bok)
  28.   punkty = punkty +1
  29.   GraphicsWindow.Title = "Masz juz " + punkty + " punktow!"
  30.   Timer.Interval = 200
  31.   Timer.Tick = rusz_ksztalt
  32. EndSub
  33.  
  34.  
  35. Sub rusz_ksztalt
  36.   Shapes.Move(ksztalt, x, y)
  37.   y = y + bok
  38.   zat_ruchu()
  39. EndSub
  40.  
  41. Sub zat_ruchu
  42.   For z = 1 To szerokosc
  43.     For q = 1 To ksztalt_szer
  44.       If y+(ksztalt_wys*bok) > granica[z] And (x/bok)+q = z Then
  45.         For w =1 To ksztalt_szer
  46.           k = granica[x+w]
  47.           granica[x+w] = k - ksztalt_wys*bok
  48.         EndFor
  49.         czy_nowy()
  50.       EndIf
  51.     EndFor
  52.   EndFor
  53. EndSub
  54.  
  55. Sub czy_nowy
  56.   For b =1 To szerokosc
  57.     If granica[b] <= 0 Then
  58.      
  59.     EndIf
  60.   EndFor
  61.   nowy_ksztalt()
  62. EndSub
  63.  
  64. Sub Klawisze
  65.    If GraphicsWindow.LastKey = "Left" Then
  66.     porusz = -1
  67.     'Sprawdz()
  68.     'If zly = 0 Then
  69.       x = x + porusz*bok
  70.     'EndIf
  71.     rusz_ksztalt()
  72.   EndIf
  73.  
  74.   If GraphicsWindow.LastKey = "Right" Then
  75.     porusz = 1
  76.     'Sprawdz()  
  77.     'If zly = 0 Then
  78.       x = x + porusz*bok
  79.     'EndIf
  80.     rusz_ksztalt()
  81.   EndIf
  82.  
  83.   If GraphicsWindow.LastKey = "Down" Then
  84.     Timer.Interval = 0
  85.   EndIf
  86. EndSub
  87.  
  88. Sub Sprawdz ' in: ypos, xpos, h, moveDirection  ret: invalidMove = 1 or -1 or 2 if move is invalid, otherwise 0
  89.   i = 0
  90.   zly = 0
  91.   While i < ksztalt
  92.     v = ksztalt
  93.  
  94.     'x/y is the box offset within the shape.
  95.     pozx = Math.Floor(v/10)
  96.     pozy = Math.Remainder(v, 10)
  97.    
  98.     If (x + pozx + porusz) < 0 Then
  99.       invalidMove = -1
  100.       i = ksztalt ' force getting out of the loop
  101.     EndIf
  102.  
  103.     If (x + pozx + porusz) >= szerokosc*bok Then
  104.       invalidMove = 1
  105.       i = ksztalt ' force getting out of the loop
  106.     EndIf
  107.  
  108.     If Array.GetValue("c", (x + pozx + porusz) + (y + pozy) * szerokosc*bok) <> "." Then
  109.       invalidMove = 2
  110.       i = ksztalt ' force getting out of the loop
  111.     EndIf
  112.  
  113.     i = i + 1
  114.   EndWhile
  115. EndSub
  116.