12345678910111213141516171819202122232425 |
- from turtle import Turtle
- from config import SCREEN_HEIGHT, PADDLE_LENGTH
- STEP = 20
- class Paddle(Turtle):
- def __init__(self, pos):
- super().__init__()
- self.shape("square")
- self.color("white")
- self.setheading(90)
- self.penup()
- # self.speed("fastest")
- self.shapesize(stretch_len=PADDLE_LENGTH, stretch_wid=1)
- self.goto(pos, 0)
- def up(self):
- y = self.ycor()
- if y < SCREEN_HEIGHT / 2 - PADDLE_LENGTH * 5 - STEP * 2:
- self.forward(STEP)
- def down(self):
- y = self.ycor()
- if y > -(SCREEN_HEIGHT / 2 - PADDLE_LENGTH * 5 - STEP * 2):
- self.backward(STEP)
|