| 108 | |
| 109 | |
| 110 | class Paddle(object): |
| 111 | def __init__(self, screen, width, height, x, y): |
| 112 | self.__screen = screen |
| 113 | self._width = width |
| 114 | self._height = height |
| 115 | self._xLoc = x |
| 116 | self._yLoc = y |
| 117 | w, h = pygame.display.get_surface().get_size() |
| 118 | self.__W = w |
| 119 | self.__H = h |
| 120 | |
| 121 | def draw(self): |
| 122 | """ |
| 123 | draws the paddle onto screen. |
| 124 | """ |
| 125 | pygame.draw.rect( |
| 126 | screen, (0, 0, 0), (self._xLoc, self._yLoc, self._width, self._height), 0 |
| 127 | ) |
| 128 | |
| 129 | def update(self): |
| 130 | """ |
| 131 | moves the paddle at the screen via mouse |
| 132 | """ |
| 133 | x, y = pygame.mouse.get_pos() |
| 134 | if x >= 0 and x <= (self.__W - self._width): |
| 135 | self._xLoc = x |
| 136 | |
| 137 | |
| 138 | """ |