Facebook
From Marcel , 3 Years ago, written in Visual Basic.
Embed
Download Paste or View Raw
Hits: 122
  1. GraphicsWindow.Height = 580
  2.   GraphicsWindow.Width = 700
  3.   GraphicsWindow.Show()
  4.  
  5. szerokosc=10
  6. wysokosc=20
  7. bok=30
  8. SetupCanvas()
  9.  
  10. For i=1 To szerokosc
  11.   For j=1 To wysokosc
  12.     GraphicsWindow.DrawRectangle((i-1)*bok, (j-1)*bok,bok,bok)
  13.   EndFor
  14. EndFor
  15. punkty=0
  16. nowy_ksztalt()
  17.  
  18. For z=1 to szerokosc
  19. granica[z] = GraphicsWindow.Height
  20. Endfor
  21.  
  22. Sub nowy_ksztalt
  23.   x=0
  24.   y=0
  25.   ksztalt=0
  26.   ksztalt_szer=math.GetRandomNumber(3)
  27.   ksztalt_wys=Math.GetRandomNumber(3)
  28.   GraphicsWindow.BrushColor=GraphicsWindow.GetRandomColor()
  29.   ksztalt=Shapes.AddRectangle(ksztalt_szer*bok,ksztalt_wys*bok)
  30.   punkty=punkty+1
  31.   PokazPunkty()
  32.   GraphicsWindow.Title="Small Basic Tetris"
  33. EndSub
  34. Timer.Interval=200
  35. Timer.Tick=rusz_ksztalt
  36. Sub rusz_ksztalt
  37.   Shapes.Move(ksztalt,x,y)
  38.   y=y+bok
  39.   zat_ruchu()
  40. EndSub
  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.         granica [(x/bok)+w]=y-bok
  47.       EndFor
  48.       czy_nowy()
  49.     EndIf
  50.   EndFor
  51.  EndFor
  52. EndSub
  53.  
  54. Sub czy_nowy
  55.   For b=1 To szerokosc
  56.     If granica[b] <=0 Then
  57.      
  58.     EndIf
  59.   EndFor
  60.   nowy_ksztalt()
  61. EndSub
  62.  
  63. GraphicsWindow.KeyDown = sterowanie
  64. Sub sterowanie
  65.   If GraphicsWindow.LastKey = "Left" Then
  66.     Shapes.Move(ksztalt,x,y)
  67.     x = x - bok
  68.   EndIf
  69.   If GraphicsWindow.LastKey = "Right" Then
  70.     Shapes.Move(ksztalt,x,y)
  71.     x = x + bok
  72.   EndIf
  73.  EndSub
  74.  
  75.      
  76.      Sub SetupCanvas
  77.        
  78.   GraphicsWindow.PenWidth = 6
  79.   GraphicsWindow.PenColor = "Black"
  80.   GraphicsWindow.DrawLine(XOFFSET, YOFFSET, XOFFSET, YOFFSET + wysokosc*bok)
  81.   GraphicsWindow.DrawLine(XOFFSET + szerokosc*bok, YOFFSET, XOFFSET + szerokosc*bok, YOFFSET + wysokosc*bok)
  82.   GraphicsWindow.DrawLine(XOFFSET, YOFFSET + wysokosc*bok, XOFFSET + szerokosc*bok, YOFFSET + wysokosc*bok)
  83.  
  84.   GraphicsWindow.PenColor = "Black"
  85.   GraphicsWindow.BrushColor = "Blue"
  86.   x = 350
  87.   y = 100
  88.  
  89.   GraphicsWindow.FillRectangle(x - 20, y + 190, 310, 170)
  90.   GraphicsWindow.DrawRectangle(x - 20, y + 190, 310, 170)
  91.  
  92.   GraphicsWindow.BrushColor = "Black"
  93.   GraphicsWindow.FontItalic = "False"
  94.   GraphicsWindow.FontName = "Tahoma"
  95.   GraphicsWindow.FontSize = 16
  96.   GraphicsWindow.DrawText(350, 350, "Sterowanie:")
  97.   GraphicsWindow.DrawText(350, 390, "Strzałka w lewo = Ruch w lewo")
  98.   GraphicsWindow.DrawText(350, 370, "Strzałka w prawo = Ruch w prawo")
  99.  
  100.   GraphicsWindow.BrushColor = "Black"
  101.   GraphicsWindow.FontName = "Tahoma"
  102.   GraphicsWindow.FontItalic = "True"
  103.   GraphicsWindow.FontSize = 36
  104.   GraphicsWindow.DrawText(320,  100, "Small Basic Tetris")
  105.   GraphicsWindow.DrawText(320,  200, "Punkty:")
  106.   PokazPunkty()
  107.  
  108. EndSub
  109.    
  110.   XOFFSET = 40  
  111.   YOFFSET = 40  
  112.  
  113.   Sub PokazPunkty
  114.   GraphicsWindow.PenWidth = 6
  115.   GraphicsWindow.BrushColor = "Blue"
  116.   GraphicsWindow.FillRectangle(500, 200, 100, 50)
  117.   GraphicsWindow.BrushColor = "Black"
  118.   GraphicsWindow.DrawRectangle(500, 200, 100, 50)
  119.   GraphicsWindow.FontItalic = "False"
  120.   GraphicsWindow.FontSize = 32
  121.   GraphicsWindow.FontName = "Impact"
  122.   GraphicsWindow.BrushColor = "Black"
  123.   GraphicsWindow.DrawText(515, 205, Text.Append(Text.GetSubText( "00000000", 0, 8 - Text.GetLength( punkty ) ), punkty))
  124. EndSub