Beispiel #1
0
def make_world(constructor):

    # create TurtleWorld
    world = TurtleWorld()
    world.delay = .01
    world.setup_run()

    # make three Wobblers with different speed and clumsiness attributes
    colors = ['orange', 'green', 'purple']
    i = 1.0
    for color in colors:
        t = constructor(world, i, i * 30, color)
        i += 0.5

    return world
def make_world(constructor):

    # create TurtleWorld
    world = TurtleWorld()
    world.delay = .01
    world.setup_run()

    # make three Wobblers with different speed and clumsiness attributes
    colors = ['red', 'green', 'blue' ]
    i = 1.0
    for color in colors:
        t = constructor(world, i, i*30, color)
        i += 0.5

    return world
Beispiel #3
0
        # call the function that keeps the Wanderers in bounds
        self.keep_in_bounds(dist)

        # choose a random direction and turn
        dir = randint(0, self.clumsiness) - randint(0, self.clumsiness)
        self.rt(dir)

        # move forward according to the speed attribute
        self.fd(self.speed)

    def keep_in_bounds(self, dist):
        """Turns the Turtle in order to keep it in bounds."""

        # you should modify this method
        pass


# create a new TurtleWorld
world = TurtleWorld()

# add the Run, Stop, Step and Clear buttons
world.setup_run()

# make three Wanderers with different speed and clumsiness attributes
for i in range(1, 4):
    Wanderer(i, i * 45)

# tell world to start processing events (button presses, etc)
wait_for_user()
Beispiel #4
0
        # call the function that keeps the Wanderers in bounds
        self.keep_in_bounds(dist)
        
        # choose a random direction and turn
        dir = randint(0,self.clumsiness) - randint(0,self.clumsiness)
        self.rt(dir)
        
        # move forward according to the speed attribute
        self.fd(self.speed)

    def keep_in_bounds(self, dist):
        """Turns the Turtle in order to keep it in bounds."""

        # you should modify this method
        pass
        

# create a new TurtleWorld
world = TurtleWorld()

# add the Run, Stop, Step and Clear buttons
world.setup_run()

# make three Wanderers with different speed and clumsiness attributes
for i in range(1,4):
    Wanderer(i, i*45)

# tell world to start processing events (button presses, etc)
wait_for_user()