text: import pygame
  
  
  class Ball(pygame.sprite.Sprite):
  
      def __init__(self, color, width, height, velocity):
          super().__init__()
          self.image = pygame.Surface([width, height])
          pygame.draw.rect(self.image, color, [0, 0, width, height])
          self.rect = self.image.get_rect()
          self.velocity = [velocity, velocity]
  
      def update(self):
          self.rect.x += self.velocity[0]
          self.rect.y += self.velocity[1]
  
      def bounce(self):
          self.velocity[0] = self.velocity[0]
          self.velocity[1] = -self.velocity[1]
  
  