I've been makeing a game using turtle and i've set speed to 0 using turtle.speed(0), although this is not fast enough, i've done some research but i cant find any commands for python 3.9 that will deactivate animations or increasing turtle speed anymore. Can someone please help me speed up my game? (I only have python 3.9 so i can't use tracer) Heres a code sample:
import math
import turtle
char = turtle.Turtle()
char.hideturtle()
char.speed(0)
debug = True
def left():
update(50)
def right():
update(-50)
def update_prep():
update(0)
def update(x_adjust):
char.clear()
char.penup()
char.setx(char.xcor() - x_adjust)
char.pendown()
char_1()
def char_1():
char_start_pos = char.pos()
char.setheading(0)
char.left(180)
char.fillcolor('grey')
char.begin_fill()
char.forward(10)
char.right(90)
char.forward(50)
char.right(90)
char.forward(20)
char.right(90)
char.forward(50)
char.right(90)
char.end_fill()
char_pos = char.pos()
char_head = char.heading()
char.right(180)
tangent(-25, 15, True)
char.setheading(0)
char.left(180)
char.forward(0)
for _ in range(36):
char.forward(1)
char.left(10)
char.setheading(char_head)
char.goto(char_pos)
char.forward(20)
char_pos = char.pos()
char_head = char.heading()
char.left(90)
tangent(15, -25, True)
char.setheading(0)
char.left(180)
char.forward(0)
for _ in range(36):
char.forward(1)
char.left(10)
char.setheading(char_head)
char.goto(char_pos)
char.right(90)
char.forward(50)
char.left(90)
char_pos = char.pos()
char_head = char.heading()
tangent(-25, 15, True)
char.setheading(0)
char.left(0)
char.forward(0)
for _ in range(36):
char.forward(1)
char.left(10)
char.setheading(char_head)
char.goto(char_pos)
char.right(180)
char.forward(20)
char.left(90)
char.right(0)
tangent(15, -25, True)
char.setheading(0)
char.left(0)
char.forward(0)
for _ in range(36):
char.forward(1)
char.left(10)
char.penup()
char.goto(char_start_pos)
char.pendown()
def tangent(tangent_height, tangent_width, custom_heading):
if not custom_heading:
char.setheading(270)
angle = math.atan(tangent_width / tangent_height)
angle = angle * 57.295779513082321578272654463367
char.left(angle)
if debug:
print(angle)
length = tangent_height*tangent_height + tangent_width*tangent_width
length = math.sqrt(length)
char.forward(length)
char_1()
turtle.onkey(left, 'a')
turtle.onkey(right, 'd')
turtle.onkey(update_prep, 'w')
turtle.listen()
turtle.mainloop()