--  This program written by Nerd_Herd and Rick3137 at

      --  Scratch.mit.edu

screen (1000,600,32,"Hexagon")     -- Starts Program

pendown = 0  cnt = 0  PenX = 500  PenY = 10  Angle2 = 0  x2 = 0  y2 = 0  dx = 0

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

 key = 0

                -- Create functions at start of program

                -- 1 Radian = 57.2958 Degrees.

                -- 1 degree = .0174532925 Radians

                -- math degrees = 450 - compass

function SetColor() color (red,green,blue) end

function ChangeColor(n)

    blue = blue + n

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

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

    if red > 255 then green = 0 ; red = 0 blue =0 end

    color (red,green,blue)

 end

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

function RotateRight(n) Angle = Angle + n 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 > 359.9999999 then n = n - 360 end

    return n

end

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

     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 "

     dy = sin (Angle3)

     x2 = PenX + dx * n

     y2 = PenY + dy * n

     if pendown == 1 then line(PenX*2,PenY*2,x2*2,y2*2) end

     PenX = x2 PenY = y2

     return PenX

 end



Angle4 = 10

PenX = 300  PenY = 160

color (250,220,0)            -- sets color to green

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

clearscreen()

redraw()

Angle = 90

pendown = 1                -- simulates a Scratch " Pendown " block


d = 0


    while cnt2 < 100

    do

    wait(600)

    Angle4 = Angle4 + 1

    clearscreen()

    redraw()

    cnt = 0


          while cnt < 600

          do

          ChangeColor(1)

          RotateRight( 180 - Angle4 )

          MoveSteps ( 250 )

          cnt = cnt + 1

          end

          if Angle4 > 90 then Angle4 = 10 ; PenX = 300 ; PenY = 160 end

    sync()

    key = getkey()

    if key == 32 then cnt2 = 200 end

    end


closewindow()             -- This ends the program.





 
Make a Free Website with Yola.