I'm using pygame to create a basic 3d renderer, was the WASD movement is extremely primitive. The keys act like the do in a text editor, every time you press it it takes half a second to start repeating extremely fast. How do I stop this from happening and make the keys repeat at a constant rate no matter what I'm pressing, like a normal 3d game.Here's my code:
import pygameimport turtleimport timepygame.init()turtle.hideturtle()focalLength = 2tx = 0ty = 0tz = 0def pos(x, y, z): global focalLength x = x+tx y = y+ty z = z+tz screenX = focalLength*(x/z) screenY = focalLength*(y/z) turtle.setpos(screenX, screenY)def render(): turtle.tracer(0) turtle.up() drawSquare() turtle.update()def drawSquare(): pos(-50, -50, 3) turtle.down() pos(50, -50, 3) pos(50, 50, 3) pos(-50, 50, 3) pos(-50, -50, 3) turtle.up() pos(-50, -50, 1.5) turtle.down() pos(50, -50, 1.5) pos(50, 50, 1.5) pos(-50, 50, 1.5) pos(-50, -50, 1.5) turtle.up() pos(-50, -50, 1.5) turtle.down() pos(-50, -50, 3) turtle.up() pos(50, -50, 1.5) turtle.down() pos(50, -50, 3) turtle.up() pos(50, 50, 1.5) turtle.down() pos(50, 50, 3) turtle.up() pos(-50, 50, 1.5) turtle.down() pos(-50, 50, 3) turtle.up()def keys(): global tx, ty, tz for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_d: tx = tx-10 if event.key == pygame.K_a: tx = tx+10 if event.key == pygame.K_s: tz = tz+0.1 if event.key == pygame.K_w: tz = tz-0.1while True: render() keys() turtle.clear()I've looked through StackOverflow and tested the different solutions I came across, but they didn't work.I am using Trinket.io, as I am on a Chromebook and am making this for Maths. I'm trying to get simple movement like any game would have so while the key is pressed down, it constantly moves the player until the key is let go, but the rest of the code still runs, so more keys can be pressed and graphics can be rendered.
if the previous answers: pygame.key.get_pressed() does not work in trinket.ioso I cannot use both of those answers given to me