Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to make an object's clones follow the same function

$
0
0

I have an object, let's call it 'ant', and I made it move, and every 10 second I make a clone of it,but the clone doesn't follow the same function that the ant had.

Is there a way to make the clones follow the same function?There will be about 10 or 20 more clones.

import turtleimport random#make a variable moves and create an object antmoves = 0ant = turtle.Turtle()#I make the direction of the ant randomant.setheading(random.randint(0, 360))#create A definition that makes the ant move and creates a clonedef move():    ant.forward(10)    if moves == 10:        ant.clone()    else:        moves += 1move()

Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>