Facebook
From Botched Sheep, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 46
  1. GraphicsWindow.Height = 700
  2. GraphicsWindow.Width = 580
  3. GraphicsWindow.BackgroundColor = "LightBlue"
  4. GraphicsWindow.Title = "Tetris"
  5. GraphicsWindow.CanResize = "False"
  6.  
  7. While "True"
  8.   BOXES = 4 'liczba bloków na klocek
  9.   BWIDTH = 25
  10.   XOFFSET = 40
  11.   YOFFSET = 40
  12.   CWIDTH = 10
  13.   CHEIGHT = 20
  14.   STARTDELAY = 800
  15.   ENDDELAY = 175
  16.   PREVIEW_xpos = 13
  17.   PREVIEW_ypos = 2
  18.  
  19.   SzablonyPudelek()
  20.   UstawieniePlotna()
  21.   GlownaPetla()
  22. EndWhile
  23.  
  24. Sub GlownaPetla
  25.   template = Text.Append("template", Math.GetRandomNumber(4))
  26.   StworzKlocek()
  27.   nastepnyKlocek = h
  28.  
  29.   koniec = 0
  30.   sessionDelay = STARTDELAY
  31.   While koniec
  32.     If sessionDelay > ENDDELAY Then
  33.       sessionDelay = sessionDelay - 1
  34.     EndIf
  35.    
  36.     delay = sessionDelay
  37.     tenKlocek = nastepnyKlocek
  38.    
  39.     template = Text.Append("template", Math.GetRandomNumber(4))
  40.    
  41.     StworzKlocek()
  42.     nastepnyKlocek = h
  43.     NarysujKlocek()
  44.    
  45.     h = tenKlocek
  46.     ypos = 0
  47.     done = 0
  48.     xpos = 3
  49.    
  50.     'Tutaj dodac subrutne checkStop()
  51.     If done = 1 Then
  52.       ypos = ypos - 1
  53.       'Tutaj dodac subrutne ruchKlocka()
  54.       koniec = 1
  55.     EndIf
  56.   EndWhile
  57. EndSub
  58.  
  59. Sub checkStop
  60.   done = 0
  61.   i = 0
  62.   While i < BOXES
  63.     v = Array.GetValue(Array.GetValue(h, -1), i)
  64.    
  65.    
  66.   EndWhile
  67. EndSub
  68.  
  69. Sub NarysujKlocek
  70.   xpos = PREVIEW_xpos
  71.   ypos = PREVIEW_ypos
  72.   h = nastepnyKlocek
  73.  
  74.   XOFFSETBK = XOFFSET
  75.   YOFFSETBK = YOFFSET
  76.  
  77.   XOFFSET = XOFFSET + Array.GetValue(Array.GetValue(h, -1), "pviewx")
  78.   YOFFSET = YOFFSET + Array.GetValue(Array.GetValue(h, -1), "pviewy")
  79.   StworzKlocek()
  80.  
  81.   XOFFSET = XOFFSETBK
  82.   YOFFSET = YOFFSETBK
  83. EndSub
  84.  
  85. Sub StworzKlocek
  86.   hcount = hcount + 1
  87.   h = Text.Append("piece", hcount)
  88.  
  89.   Array.SetValue(h, -1, template)
  90.  
  91.   GraphicsWindow.PenWidth = 1
  92.   GraphicsWindow.PenColor = "Black"
  93.   GraphicsWindow.BrushColor = Array.GetValue(template, "color")
  94.  
  95.   For i = 0 To BOXES - 1
  96.     s = Shapes.AddRectangle(BWIDTH, BWIDTH)
  97.     Shapes.Move(s, -BWIDTH, BWIDTH)
  98.     Array.SetValue(h, i, s)
  99.   EndFor
  100. EndSub
  101.  
  102. Sub UstawieniePlotna
  103.   GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
  104.   GraphicsWindow.FillRectangle(XOFFSET, YOFFSET, BWIDTH*CWIDTH, BWIDTH * CHEIGHT)
  105.  
  106.   GraphicsWindow.PenWidth = 2
  107.   GraphicsWindow.PenColor = "Red"
  108.  
  109.   For x = 0 To CWIDTH-1
  110.     For y = 0 To CHEIGHT-1
  111.       Array.SetValue("c", x + y * CWIDTH, ".")
  112.       GraphicsWindow.DrawRectangle(XOFFSET+x*BWIDTH, YOFFSET+y*BWIDTH, BWIDTH, BWIDTH)
  113.     EndFor
  114.   EndFor
  115.  
  116.   GraphicsWindow.PenWidth = 4
  117.   GraphicsWindow.PenColor = "Lime"
  118.  
  119.   GraphicsWindow.BrushColor = "Pink"
  120.   x = XOFFSET + PREVIEW_xpos*BWIDTH-BWIDTH
  121.   y = YOFFSET + PREVIEW_ypos*BWIDTH-BWIDTH
  122.  
  123.   GraphicsWindow.FillRectangle(x, y, BWIDTH*5, BWIDTH*6)
  124.  
  125.   GraphicsWindow.FillRectangle(x - 20, y + 190, 310, 170)
  126.   GraphicsWindow.BrushColor = "Black"
  127.   GraphicsWindow.FontSize = 16
  128.  
  129.   GraphicsWindow.DrawText(x, y + 200, "Sterowanie")
  130.   GraphicsWindow.DrawText(x + 25, y + 220, "- Lewa strzałka")
  131.   GraphicsWindow.DrawText(x + 25, y + 240, "- Prawa strzałka")
  132.   GraphicsWindow.DrawText(x + 25, y + 260, "- Strzałka w górę")
  133.   GraphicsWindow.DrawText(x + 25, y + 280, "- Strzałka w dół")
  134.  
  135.   score = 0
  136.   WyswietlaniePunktow()
  137. EndSub
  138.  
  139. Sub WyswietlaniePunktow
  140.   GraphicsWindow.BrushColor = "Pink"
  141.   GraphicsWindow.FillRectangle(500, 65, 150, 100)
  142.   GraphicsWindow.FontSize = 32
  143.   GraphicsWindow.DrawText(505, 70, Text.Append(Text.GetSubText("00000000", 0, 8 - Text.GetLength(score)), score))
  144. EndSub
  145.  
  146. Sub SzablonyPudelek
  147.   Array.SetValue("template1", 0, 01)
  148.   Array.SetValue("template1", 1, 11)
  149.   Array.SetValue("template1", 2, 21)
  150.   Array.SetValue("template1", 3, 20)
  151.   Array.SetValue("template1", "color", "Yellow")
  152.   Array.SetValue("template1", "pviewx", 12)
  153.   Array.SetValue("template1", "pviewy", 12)
  154.  
  155.   Array.SetValue("template2", 0, 01)
  156.   Array.SetValue("template2", 1, 11)
  157.   Array.SetValue("template2", 2, 10)
  158.   Array.SetValue("template2", 3, 12)
  159.   Array.SetValue("template2", "color", "Blue")
  160.   Array.SetValue("template2", "pviewx", 0)
  161.   Array.SetValue("template2", "pviewy", 25)
  162.  
  163.   Array.SetValue("template3", 0, 01)
  164.   Array.SetValue("template3", 1, 11)
  165.   Array.SetValue("template3", 2, 21)
  166.   Array.SetValue("template3", 3, 22)
  167.   Array.SetValue("template3", "color", "Red")
  168.   Array.SetValue("template3", "pviewx", 5)
  169.   Array.SetValue("template3", "pviewy", 10)
  170.  
  171.   Array.SetValue("template4", 0, 00)
  172.   Array.SetValue("template4", 1, 01)
  173.   Array.SetValue("template4", 2, 02)
  174.   Array.SetValue("template4", 3, 11)
  175.   Array.SetValue("template4", "color", "Black")
  176.   Array.SetValue("template4", "pviewx", 13)
  177.   Array.SetValue("template4", "pviewy", 13)
  178.  
  179. EndSub