the-honk/school/a-level/Y13 2021-2023/OOP/Breakout/paddle.py
2024-10-09 18:02:48 +01:00

20 lines
No EOL
535 B
Python

from element import Element
BLACK = (0, 0, 0)
class Paddle(Element):
def __init__(self, width, height, startPosition, colour, screenWidth):
super().__init__(width, height, startPosition, colour)
self.__screenWidth = screenWidth - width
def moveLeft(self, px):
self.rect.x -= px
if self.rect.x < 0:
self.rect.x = 0
def moveRight(self, px):
self.rect.x += px
if self.rect.x > self.__screenWidth:
self.rect.x = self.__screenWidth