Dec-30-2022, 05:52 PM
omgomgomg thank you so much! the paddles are moving now, but now idk how to get the ball moving... ik this code looks alot like the code you showed me, sry for that, i'm still learning the basics of python/turtle
import turtle class Paddle (turtle.Turtle): def __init__(self, x, keys=None, color='white'): super().__init__() self.speed(3) self.shape('square') self.shapesize(stretch_wid=5, stretch_len=1) self.color(color) self.penup() self.goto(x, 0) if keys: wn.onkeypress(lambda: self.move_y(20), keys[0]) wn.onkeypress(lambda: self.move_y(-20), keys[1]) def move_y(self, step): self.sety(self.ycor()+step) class Ball (turtle.Turtle): def __init__(self, color='white', keys=None): super().__init__() self.speed(3) self.shape('circle') self.color(color) self.penup() self.goto(0, 0) wn = turtle.Screen() wn.setup(width=800, height=600) paddles = (Paddle(-350, "ad"), Paddle(350, "jl")) ball = Ball() wn.bgcolor('yellow') wn.title('pong') wn.listen() while True: wn.update()