Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster drawing in python

I got program that draws spaceship (Turtle Graphics) forward,backward etc.

By using a lot of orders and lines drawing spaceship takes 5 seconds using turtle.speed(0).

And whenever you click the right/left key it draws it again in other direction. It major thing in my project. Is there a way to draw it faster? Thanks in advance.

like image 516
Liron Lavi Avatar asked May 22 '26 20:05

Liron Lavi


2 Answers

By default, turtle has a draw delay of 10 milliseconds. Every time it updates the canvas, it will pause 10 milliseconds as a simple way of controlling the animation speed. This delay is independent of the speed of the turtle itself. If you want to speed up the animation, you can set a shorter delay, e.g. with turtle.delay(3) or turtle.delay(0).

Note that turtle graphics are more of an educational tool than a serious way to do graphics. If you don't have a specific reason to use turtle, consider switching to other graphics libraries.

like image 153
user2357112 supports Monica Avatar answered May 25 '26 09:05

user2357112 supports Monica


you can use screen.tracer(n) where a bigger n value means a faster drawing speed but less details

like image 30
Liam Avatar answered May 25 '26 09:05

Liam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!