main.py
def on_mouse_motion(self, x, y, dx, dy):
        """
        Move the paddle based on the position of the mouse
        """
        # align paddle with the mouse and get x-axis rate of change
        self.paddle_sprite.center_x = x
        self.paddle_sprite.change_x = dx
        
        # prevent paddle from overlapping left or right wall
        if self.paddle_sprite.left < WALL_THICKNESS:
            self.paddle_sprite.left = WALL_THICKNESS
        elif self.paddle_sprite.right > SCREEN_WIDTH - WALL_THICKNESS:
            self.paddle_sprite.right = SCREEN_WIDTH - WALL_THICKNESS
        
        # if the ball hasn't started moving yet, match it's position to just above the center of the paddle
        if self.ball_sprite.change_y == 0:
            self.ball_sprite.bottom = self.paddle_sprite.top + 1
            self.ball_sprite.center_x = self.paddle_sprite.center_x

        Move the paddle based on the position of the mouse
        
Move the paddle based on the position of the mouse
Move the paddle based on the position of the mouse
def on_mouse_motion(self, x, y, dx, dy):
        self.paddle_sprite.center_x = x
        self.paddle_sprite.change_x = dx
        if self.paddle_sprite.left < WALL_THICKNESS:
            self.paddle_sprite.left = WALL_THICKNESS
        elif self.paddle_sprite.right > SCREEN_WIDTH - WALL_THICKNESS:
            self.paddle_sprite.right = SCREEN_WIDTH - WALL_THICKNESS
        if self.ball_sprite.change_y == 0:
            self.ball_sprite.bottom = self.paddle_sprite.top + 1
            self.ball_sprite.center_x = self.paddle_sprite.center_x
def on_mouse_motion ( self , x , y , dx , dy ) : self . paddle_sprite . center_x = x self . paddle_sprite . change_x = dx if self . paddle_sprite . left < WALL_THICKNESS : self . paddle_sprite . left = WALL_THICKNESS elif self . paddle_sprite . right > SCREEN_WIDTH - WALL_THICKNESS : self . paddle_sprite . right = SCREEN_WIDTH - WALL_THICKNESS if self . ball_sprite . change_y == 0 : self . ball_sprite . bottom = self . paddle_sprite . top + 1 self . ball_sprite . center_x = self . paddle_sprite . center_x
Move the paddle based on the position of the mouse
Move the paddle based on the position of the mouse
"""
        Move the paddle based on the position of the mouse
        """ # align paddle with the mouse and get x-axis rate of change # prevent paddle from overlapping left or right wall # if the ball hasn't started moving yet, match it's position to just above the center of the paddle
self
x
y
dx
dy