def ShowStatus():
    """
    Displays the Spiral Size & Group Size
    """
    global grpSize, spiralSize

    tu3.clear()

    # Update Group Size
    pos = tf.PositionText(tt, txtPosition=1, vMargin=37)
    tf.GoToPos(tu3, pos)
    tf.ShowText(tu3,
                "Group Size: " + str(grpSize),
                txtAlign="left",
                fontColor="black",
                fontSize=14)

    # Update Speed Level Display
    pos = (pos[0], pos[1] - 25)
    tf.GoToPos(tu3, pos)
    tf.ShowText(tu3,
                "Spiral Size: " + str(spiralSize),
                txtAlign="left",
                fontColor="black",
                fontSize=14)
Exemple #2
0
def ShowStatus():
    """
    Displays the Spiral Size & Group Size
    """
    global grpSize, bendAngle

    tu3.clear()

    # Update Group Size
    pos = tf.PositionText(tt, txtPosition=1, vMargin=37)
    tf.GoToPos(tu3, pos)
    tf.ShowText(tu3,
                "Number Of Spokes: " + str(grpSize),
                txtAlign="left",
                fontColor="black",
                fontSize=14)

    # Update Kink Ange
    pos = (pos[0], pos[1] - 25)
    tf.GoToPos(tu3, pos)
    tf.ShowText(tu3,
                "Kink Angle: " + str(bendAngle),
                txtAlign="left",
                fontColor="black",
                fontSize=14)
Exemple #3
0
def DrawSpiral():
    global colorIndexSpiral, colorListSpiral, colorCountSpiral
    global colorIndexScreen, colorListScreen, colorCountScreen
    global musicIndex, musicCount, mVol
    global musicListFullPaths, musicListFileNames
    global isPlayOn, isExitMode, spiralSize, grpSize, spiralType
    """
    Apparently, global declaration is not needed for object variables.
    """
    while True:
        if isExitMode:
            break

        if not isPlayOn:
            # Discontinue & display Stop notice
            tu3.clear()
            pos = tf.PositionText(tt, txtPosition=1, vMargin=35)
            tf.GoToPos(tu3, pos)
            tf.ShowText(tu3,
                        "Play Stopped: Click RESUME To Start Afresh",
                        txtAlign="left",
                        fontColor="red",
                        fontSize=14)
            break

        # Display Status:
        ShowStatus()

        # Set screen color as per color list
        clr = colorListScreen[colorIndexScreen]
        ts.bgcolor(clr)

        # Set spiral color as per color list
        clr = colorListSpiral[colorIndexSpiral]
        rr = clr[0]
        gg = clr[1]
        bb = clr[2]

        DrawSpokeSpiral(tu1, cRed=rr, cGreen=gg, cBlue=bb)

        colorIndexSpiral = colorIndexSpiral + 1
        if colorIndexSpiral > (colorCountSpiral - 1):
            colorIndexSpiral = 0

        colorIndexScreen = colorIndexScreen + 1
        if colorIndexScreen > (colorCountScreen - 1):
            colorIndexScreen = 0

        time.sleep(2)
def ClickAction(x, y):
    global lbAreaList, isPlayOn
    global colorIndexSpiral, colorIndexScreen
    global colorCountSpiral, colorCountScreen
    global spiralSize, grpSize

    lbResume = lbAreaList[0]
    lbStop = lbAreaList[1]
    lbBigger = lbAreaList[2]
    lbShorter = lbAreaList[3]
    lbMore = lbAreaList[4]
    lbLess = lbAreaList[5]
    lbExit = lbAreaList[6]
    if (x in range(lbResume[0], lbResume[2])
            and y in range(lbResume[3], lbResume[1])):
        if not isPlayOn:
            isPlayOn = True
            CallSpirals()

    elif (x in range(lbStop[0], lbStop[2])
          and y in range(lbStop[3], lbStop[1])):
        isPlayOn = False

    elif (x in range(lbBigger[0], lbBigger[2])
          and y in range(lbBigger[3], lbBigger[1])):
        spiralSize = spiralSize + 10
        if spiralSize > 150:
            spiralSize = 150
        else:
            CallSpirals()

    elif (x in range(lbShorter[0], lbShorter[2])
          and y in range(lbShorter[3], lbShorter[1])):
        if spiralSize > 50:
            spiralSize = spiralSize - 10
            CallSpirals()
        else:
            spiralSize = spiralSize - 5
            if spiralSize < 15:
                spiralSize = 15
            else:
                CallSpirals()

    elif (x in range(lbMore[0], lbMore[2])
          and y in range(lbMore[3], lbMore[1])):
        grpSize = grpSize + 1
        if grpSize > 15:
            grpSize = 15
        else:
            CallSpirals()

    elif (x in range(lbLess[0], lbLess[2])
          and y in range(lbLess[3], lbLess[1])):
        grpSize = grpSize - 1
        if grpSize < 2:
            grpSize = 2
        else:
            CallSpirals()

    elif (x in range(lbExit[0], lbExit[2])
          and y in range(lbExit[3], lbExit[1])):
        if isPlayOn:
            isPlayOn = False
            tu4.clear()

            pos = (lbExit[2] + 10, lbExit[3])
            tf.GoToPos(tu4, pos)
            tf.ShowText(tu4,
                        "Please Click Exit Again",
                        txtAlign="left",
                        fontColor="red",
                        fontSize=14)

        else:
            time.sleep(1)  # Prevents trce-back error messages on python shell
            # Close turtle window
            ts.bye()
            sys.exit()
# For un-hiding the turtles, use showturtle command like tu1.st()
tu1.ht()
tu2.ht()
tu3.ht()
tu4.ht()

# Make Labels:
lbList = [["RESUME", "green"], ["STOP", "red"], ["BIGGER", "black"],
          ["SHORTER", "black"], ["MORE", "black"], ["LESS", "black"],
          ["EXIT", "red"]]

# txtPosition=1 results in positioning the text at top left corner.
pos = tf.PositionText(tt, txtPosition=1, vMargin=105)

for s in lbList:
    tf.GoToPos(tu2, pos)
    lbAreaList.append(
        tf.MakeLabel(tu2,
                     txtString=s[0],
                     txtAlign="center",
                     fontColor=s[1],
                     fontName="Times New Roman",
                     fontSize=14,
                     fontWt="bold",
                     labelWd=lbWidth,
                     labelHt=30,
                     borderThickness=4,
                     borderColor="blue",
                     topMargin=11))

    pos = (pos[0], pos[1] - 50)
Exemple #6
0
def ClickAction(x, y):
    global lbAreaList, isPlayOn, isExitMode
    global colorIndexSpiral, colorIndexScreen
    global colorCountSpiral, colorCountScreen
    global spiralSize, grpSize, bendAngle

    lbResume = lbAreaList[0]
    lbStop = lbAreaList[1]
    lbKinkier = lbAreaList[2]
    lbFlatter = lbAreaList[3]
    lbMore = lbAreaList[4]
    lbLess = lbAreaList[5]
    lbExit = lbAreaList[6]
    if (x in range(lbResume[0], lbResume[2])
            and y in range(lbResume[3], lbResume[1])):
        if not isPlayOn:
            isPlayOn = True
            CallSpirals()

    elif (x in range(lbStop[0], lbStop[2])
          and y in range(lbStop[3], lbStop[1])):
        isPlayOn = False

    elif (x in range(lbKinkier[0], lbKinkier[2])
          and y in range(lbKinkier[3], lbKinkier[1])):
        bendAngle = bendAngle + 10
        if bendAngle > 55:
            bendAngle = 55
        else:
            CallSpirals()

    elif (x in range(lbFlatter[0], lbFlatter[2])
          and y in range(lbFlatter[3], lbFlatter[1])):
        bendAngle = bendAngle - 10
        if bendAngle < 15:
            bendAngle = 15
        else:
            CallSpirals()

    elif (x in range(lbMore[0], lbMore[2])
          and y in range(lbMore[3], lbMore[1])):
        grpSize = grpSize + 10
        if grpSize > 210:
            grpSize = 210
        else:
            CallSpirals()

    elif (x in range(lbLess[0], lbLess[2])
          and y in range(lbLess[3], lbLess[1])):
        grpSize = grpSize - 10
        if grpSize < 20:
            grpSize = 20
        else:
            CallSpirals()

    elif (x in range(lbExit[0], lbExit[2])
          and y in range(lbExit[3], lbExit[1])):
        isExitMode = True

        if isPlayOn:
            isPlayOn = False
            tu4.clear()

            pos = (lbExit[2] + 10, lbExit[3])
            tf.GoToPos(tu4, pos)
            tf.ShowText(tu4,
                        "Please Click Exit Again",
                        txtAlign="left",
                        fontColor="red",
                        fontSize=14)

        else:
            # Prevents trace-back error messages on python shell
            time.sleep(1)
            # Close turtle window
            ts.bye()
            sys.exit()