create a list of clones of any sprite! def clone(sprite, loop): clonedsprites = [sprite]…
- User
create a list of clones of any sprite!
def clone(sprite, loop): cloned_sprites = [sprite] for counter in range(loop): # creates an exact copy of a sprite sprite = sprite.clone() cloned_sprites.append(sprite) sprite.move_forward(100)
have all the clones do the same thing!
def clone_move(cloned_sprites): for sprite in cloned_sprites: sprite.say("Now I have time for "+ random.choice(["homework", "chores", "fun"]) + "!") sprite.set_x_speed(random.randint(-5, 5)) sprite.set_y_speed(random.randint(-5, 5))
make the clones disappear!
def fusion(cloned_sprites): # Remove the first sprite from the list cloned_sprites.remove(cloned_sprites[0]) opacity_minus = random.random() for clone in cloned_sprites: clone.set_opacity(opacity_minus) opacity_minus -= .1 stage.wait(.2) stage.remove_sprite(clone) sprite.say("Hey! Where'd they go?!")
sprite = codesters.Sprite("person10", -200, -100) action = sprite.move_forward(50)
clone_list = clone(sprite, 4)
clone_move(clone_list)
fusion(clone_list)
WARNING: This program has a syntax error, which means we need to fix it!
Add a return statement for cloned_sprites on line 9 so the other functions can run!
- Assistant
- User
'NoneType' object has no attribute 'wait' on line: 26
- Assistant
The error
'NoneType' object has no attribute 'wait'suggests that thestageobject is set toNone, which is why it doesn't have awaitattribute. Thestageobject is typically provided by the environment where this script runs, such as a classroom coding platform like Codesters.In the example code I previously provided, I had set
stage = Noneas a placeholder to indicate that you need to replace it with the appropriate stage object from your environment. If you are indeed running this script in an environment where a object exists, you should ensure that you have initialized the correctly and that you have access to it before calling or any other methods on it. - User
give me all the code together
- Assistant