- i am building a pong game using python and my paddle is not responding towards keys. Why?
It’s showing error
TypeError: unsupported operand type(s) for -: ‘method’ and ‘int’
my code is in image and also this one:-
from turtle import Screen, Turtle
screen = Screen()
screen.bgcolor("black")
screen.setup(width= 800, height= 600)
screen.title("Pong Game")
screen.tracer(0)
paddle = Turtle()
paddle.shape("square")
paddle.color("white")
paddle.shapesize(stretch_wid = 5, stretch_len = 1)
paddle.penup()
paddle.goto(350, 0)
def go_up():
new_y= paddle.ycor()+ 20
paddle.goto(paddle.xcor, new_y)
def go_down():
new_y= paddle.ycor()- 20
paddle.goto(paddle.xcor, new_y)
screen.listen()
screen.onkey(go_up, "Up")
screen.onkey(go_down, "Down")
When i am pressing up key my paddle should go up but not going.enter image description here
New contributor