GraphicsWindow.Height = 700 GraphicsWindow.Width = 580 GraphicsWindow.BackgroundColor = "LightBlue" GraphicsWindow.Title = "Tetris" GraphicsWindow.CanResize = "False" While "True" BOXES = 4 'liczba bloków na klocek BWIDTH = 25 XOFFSET = 40 YOFFSET = 40 CWIDTH = 10 CHEIGHT = 20 STARTDELAY = 800 ENDDELAY = 175 PREVIEW_xpos = 13 PREVIEW_ypos = 2 SzablonyPudelek() UstawieniePlotna() GlownaPetla() EndWhile Sub GlownaPetla template = Text.Append("template", Math.GetRandomNumber(4)) StworzKlocek() nastepnyKlocek = h koniec = 0 sessionDelay = STARTDELAY While koniec If sessionDelay > ENDDELAY Then sessionDelay = sessionDelay - 1 EndIf delay = sessionDelay tenKlocek = nastepnyKlocek template = Text.Append("template", Math.GetRandomNumber(4)) StworzKlocek() nastepnyKlocek = h NarysujKlocek() h = tenKlocek ypos = 0 done = 0 xpos = 3 'Tutaj dodac subrutne checkStop() If done = 1 Then ypos = ypos - 1 'Tutaj dodac subrutne ruchKlocka() koniec = 1 EndIf EndWhile EndSub Sub checkStop done = 0 i = 0 While i < BOXES v = Array.GetValue(Array.GetValue(h, -1), i) EndWhile EndSub Sub NarysujKlocek xpos = PREVIEW_xpos ypos = PREVIEW_ypos h = nastepnyKlocek XOFFSETBK = XOFFSET YOFFSETBK = YOFFSET XOFFSET = XOFFSET + Array.GetValue(Array.GetValue(h, -1), "pviewx") YOFFSET = YOFFSET + Array.GetValue(Array.GetValue(h, -1), "pviewy") StworzKlocek() XOFFSET = XOFFSETBK YOFFSET = YOFFSETBK EndSub Sub StworzKlocek hcount = hcount + 1 h = Text.Append("piece", hcount) Array.SetValue(h, -1, template) GraphicsWindow.PenWidth = 1 GraphicsWindow.PenColor = "Black" GraphicsWindow.BrushColor = Array.GetValue(template, "color") For i = 0 To BOXES - 1 s = Shapes.AddRectangle(BWIDTH, BWIDTH) Shapes.Move(s, -BWIDTH, BWIDTH) Array.SetValue(h, i, s) EndFor EndSub Sub UstawieniePlotna GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor GraphicsWindow.FillRectangle(XOFFSET, YOFFSET, BWIDTH*CWIDTH, BWIDTH * CHEIGHT) GraphicsWindow.PenWidth = 2 GraphicsWindow.PenColor = "Red" For x = 0 To CWIDTH-1 For y = 0 To CHEIGHT-1 Array.SetValue("c", x + y * CWIDTH, ".") GraphicsWindow.DrawRectangle(XOFFSET+x*BWIDTH, YOFFSET+y*BWIDTH, BWIDTH, BWIDTH) EndFor EndFor GraphicsWindow.PenWidth = 4 GraphicsWindow.PenColor = "Lime" GraphicsWindow.BrushColor = "Pink" x = XOFFSET + PREVIEW_xpos*BWIDTH-BWIDTH y = YOFFSET + PREVIEW_ypos*BWIDTH-BWIDTH GraphicsWindow.FillRectangle(x, y, BWIDTH*5, BWIDTH*6) GraphicsWindow.FillRectangle(x - 20, y + 190, 310, 170) GraphicsWindow.BrushColor = "Black" GraphicsWindow.FontSize = 16 GraphicsWindow.DrawText(x, y + 200, "Sterowanie") GraphicsWindow.DrawText(x + 25, y + 220, "- Lewa strzałka") GraphicsWindow.DrawText(x + 25, y + 240, "- Prawa strzałka") GraphicsWindow.DrawText(x + 25, y + 260, "- Strzałka w górę") GraphicsWindow.DrawText(x + 25, y + 280, "- Strzałka w dół") score = 0 WyswietlaniePunktow() EndSub Sub WyswietlaniePunktow GraphicsWindow.BrushColor = "Pink" GraphicsWindow.FillRectangle(500, 65, 150, 100) GraphicsWindow.FontSize = 32 GraphicsWindow.DrawText(505, 70, Text.Append(Text.GetSubText("00000000", 0, 8 - Text.GetLength(score)), score)) EndSub Sub SzablonyPudelek Array.SetValue("template1", 0, 01) Array.SetValue("template1", 1, 11) Array.SetValue("template1", 2, 21) Array.SetValue("template1", 3, 20) Array.SetValue("template1", "color", "Yellow") Array.SetValue("template1", "pviewx", 12) Array.SetValue("template1", "pviewy", 12) Array.SetValue("template2", 0, 01) Array.SetValue("template2", 1, 11) Array.SetValue("template2", 2, 10) Array.SetValue("template2", 3, 12) Array.SetValue("template2", "color", "Blue") Array.SetValue("template2", "pviewx", 0) Array.SetValue("template2", "pviewy", 25) Array.SetValue("template3", 0, 01) Array.SetValue("template3", 1, 11) Array.SetValue("template3", 2, 21) Array.SetValue("template3", 3, 22) Array.SetValue("template3", "color", "Red") Array.SetValue("template3", "pviewx", 5) Array.SetValue("template3", "pviewy", 10) Array.SetValue("template4", 0, 00) Array.SetValue("template4", 1, 01) Array.SetValue("template4", 2, 02) Array.SetValue("template4", 3, 11) Array.SetValue("template4", "color", "Black") Array.SetValue("template4", "pviewx", 13) Array.SetValue("template4", "pviewy", 13) EndSub