--  This program written by Hust and Rick3137 at

      --  Scratch.mit.edu

screen (1360,700,16,"Template")     -- Starts Program

alphachannel (100)

pendown = 0  cnt = 0  PenX = 0  PenY = 0  Angle = 0 Angle2 = 0  x2 = 0  y2 = 0  dx = 0

 dy = 0 Angle3 = 0 Angle4 =0 test = 0 d = 0 cnt2 = 0 cnt3 = 0 red =0 green = 0 blue = 0

 key = 0 x1 =0  y1=0

                -- Create functions at start of program

                -- 1 Radian = 57.2958 Degrees.

                -- 1 degree = .0174532925 Radians

                -- math degrees = 450 - compass

function SetColor(r,g,b) color (r,g,b) red=r ; green = g ; blue = b  end

function ChangeColor(n)

    blue = blue + n

    if blue > 255 then blue = n-255 ; green = green + 1 end

    if green > 255 then green = 0 ; red = red + 1 end

    if red > 255 then  red = 0  end

    SetColor (red,green,blue)

 end

function GotoXY(x,y)  PenX = x ; PenY = y end

function RotateRight(n)

         Angle = Angle + n

        -- while (Angle > 360) do

               if  Angle > 360  then  Angle = Angle - 360 end

         --end



end

function RadianToDegree(n) return n * 57.2958 end

function DegreeToRadian(n) return n * .0174532925 end

function GetAngle (n)   -- A function starts with "function" and ends with "end"

    n = 450 - n

    if n > 450 then n = n - 360 end

    if n == 450 then n = 90 end

    return n

end

 function MoveSteps (n)                 -- move n steps using Angle

  n = n * 2

     --Angle = floor(Angle)

     x1 = 680 + PenX

     y1 = 350 - PenY

     Angle2 = GetAngle ( Angle )        -- The reason for all of this is because

     Angle3 = DegreeToRadian ( Angle2 ) --  I am converting angles from another language that

     dx = cos (Angle3)                   -- uses a turtle graphics type system. " Scratch "

      dx = dx* 10000  dx = floor(dx) dx = dx/10000

     dy = sin (Angle3) dy = dy* 10000  dy = floor(dy) dy = dy/10000

     x2 = x1 + dx * n

     y2 = y1 - dy * n

     x1=round(x1) y1=round(y1) x2=round(x2) y2=round(y2)

     if pendown == 1 then line(x1,y1,x2,y2) end

     PenX = PenX + dx * n   PenY = PenY + dy * n

     return PenX

 end


 function test()         -- Use for debugging

      PenX = 0  PenY = 0

      Angle = 90

      SetColor (250,0,200)            -- sets color to green

      backcolor (0,0,20)          -- sets background to blue

      clearscreen()

      redraw()

      pendown = 1

      --line(PenX,PenY,x2,y2)

      MoveSteps (100)  RotateRight(90)    MoveSteps (100)   RotateRight(90) MoveSteps (100)   RotateRight(90) MoveSteps (100)

      drawtext(50,40," angles")   drawtext(200,40,Angle)    drawtext(350,40,Angle2)    drawtext(550,40,Angle3)

      drawtext(50,60,"x1,y1,x2,y2")     drawtext(200,60,x1)    drawtext(350,60,y1)   drawtext(550,60,x2)    drawtext(750,60,y2)

      drawtext(50,80,"PenX,PenY,dx,dy")     drawtext(200,80,PenX)    drawtext(350,80,PenY)  drawtext(550,80,dx)    drawtext(750,80,dy)

      q=round(5.6)

      q=math.deg(math.pi)


      drawtext (50,100,q)

      redraw()

  end



backcolor (0,0,30)          -- sets background to blue

clearscreen()

         SetColor (251,100,0)

redraw()

pendown = 0        

        sAngle = 18

        cnt=0 sx = 0

    while cnt < 200

    do

    pendown = 0

    clearscreen()

    PenX = 0  PenY = 0

    sx = 2

    pendown = 1

            while sx < 150

            do

            ChangeColor( 240 )

                         cnt2 = 0

                         while cnt2 < 6

                         do

                               cnt3 = 0

                               while cnt3 < 2

                               do

                                     cnt4 = 0

                                     while cnt4 < 9

                                     do

                                       RotateRight( sAngle )

                                       MoveSteps ( sx )

                                       RotateRight( sAngle )

                                     cnt4 = cnt4 + 1

                                     end

                               RotateRight( 90 )

                               cnt3 = cnt3 + 1

                               end

                         redraw()

                         RotateRight( 30 )

                         cnt2 = cnt2 +1

                         end

            sx = sx + 4

            end

    sAngle = sAngle + 1

    redraw()

    wait(2000)

    cnt = cnt + 1


    key = getkey()

    if key == 32 then cnt2 = 70 end

    end


closewindow()             -- This ends the program.





 

 

Make a free website with Yola