May-18-2019, 05:31 PM
Screen.tracer(0)#turns off the screen updates
has stopped the screen updates, i removed this line.The while loop you created is not needed,
Screen.mainloop()
takes care of it.I removed the function
move
and moved the block movement code directly into the key events.Full code
import turtle # screen Screen = turtle.Screen() Screen.title("Block") Screen.bgcolor("white") Screen.setup(width=1280, height=720) # game Block = turtle.Turtle() Block.speed(0) # no slow down with animation speed Block.shape("square") # shape Block.color("black") # color not colour Block.penup() # stops drawing Block.goto(0, 0) # spawns in # fucntions def go_up(): y = Block.ycor() Block.sety(y + 20) def go_down(): y = Block.ycor() Block.sety(y - 20) def go_left(): x = Block.xcor() Block.setx(x - 20) def go_right(): x = Block.xcor() Block.setx(x + 20) # keyboard Screen.onkey(go_up, "w") Screen.onkey(go_down, "s") Screen.onkey(go_left, "a") Screen.onkey(go_right, "d") Screen.listen() Screen.mainloop()