Activities/Turtle Art: Difference between revisions

Tonyforster (talk | contribs)
Programmable Brick: added mouse code
Line 817: Line 817:
     lc.tw.save_as_image(str(x))
     lc.tw.save_as_image(str(x))
     return
     return
def myblock(lc, x):
    ###########################################################################
    #
    # Push mouse event to stack
    #
    ###########################################################################
    if lc.tw.mouse_flag == 1:
        # push y first so x will be popped first
        lc.heap.append((lc.tw.canvas.height / 2) - lc.tw.mouse_y)
        lc.heap.append(lc.tw.mouse_x - (lc.tw.canvas.width / 2))
        lc.heap.append(1) # mouse event
        lc.tw.mouse_flag = 0
    else:
        lc.heap.append(0) # no mouse event


===Understanding the Structure of the Turtle Art program===
===Understanding the Structure of the Turtle Art program===