예제 #1
0
#!/usr/bin/python
"""
This module is part of Swampy, a suite of programs available from
allendowney.com/swampy.

Copyright 2005 Allen B. Downey
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.

"""

from swampy.TurtleWorld import TurtleWorld, Turtle

# create the GUI
world = TurtleWorld(interactive=True)

# create the Turtle
turtle = Turtle()

# wait for the user to do something
world.mainloop()
    for i in range(n):
        petal(t, r, angle)
        lt(t, 360/n)           
            
def move(t , length):
    pu(t)
    fd(t, length)
    pd(t)
    
    

        
world = TurtleWorld()

bob = Turtle()



bob.set_color("yellow")
bob.set_pen_color("red")
bob.delay = 0.01

#square(bob, 50)
#polygon(bob,4,45)
#circle(bob,50)
#arc(bob,100,45)
#petal(bob,100,45)
#flower(bob,6,100,45)
move(bob, -100)
flower(bob, 7, 60.0, 60.0)
예제 #3
0
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.

"""

from swampy.TurtleWorld import Turtle
import Lumpy

# create a Lumpy object and capture reference state
lumpy = Lumpy.Lumpy()
lumpy.opaque_class(Turtle)
lumpy.make_reference()

# run the test code
z = 5

bob = Turtle()

for i in range(3):
    x = i


def function(parameter):
    local = parameter + 1

    # draw the state while function is running
    lumpy.object_diagram()


variable = 3
function(variable + 1)
#!/usr/bin/python
"""
This module is part of Swampy, a suite of programs available from
allendowney.com/swampy.

Copyright 2005 Allen B. Downey
Distributed under the GNU General Public License at gnu.org/licenses/gpl.html.

"""

import swampy.World
from swampy.TurtleWorld import TurtleWorld, Turtle

import swampy.Lumpy
lumpy = Lumpy.Lumpy()
lumpy.opaque_class(World.Interpreter)
lumpy.make_reference()

world = TurtleWorld()
bob = Turtle(world)

lumpy.object_diagram()
lumpy.class_diagram()
    # =============== Player_1_Name ================

    def player_1():
        print '----- First Turtle -----'
        global player_1_name
        player_1_name = raw_input('Please name your Turtle: ')

    player_1()

    while player_1_name == '' :
        print
        print 'You Cannot Leave This Field Empty'
        print
        player_1()

    turtle_1 = Turtle()  # Turtle_1_Player_1

    # =============== Player_1_Color ===============

    def turtle_1_color():
        global player_1_color
        player_1_color = raw_input('Please select a color for you Turtle (red,blue,yellow)')

    turtle_1_color()

    while player_1_color == 'red' or 'yellow' or 'blue':
        if player_1_color == 'red':
            turtle_1.set_color('red')
            break
        elif player_1_color == 'blue':
            turtle_1.set_color('blue')