I'm receiving the error "AttributeError: the object & # 39; Rect & # 39; it has no attribute & # 39; draw & # 39;"with this code:
import pygame import systems def finish (): pygame.quit () sys.exit () pygame.init () black = (0,0,0) white = (255,255,255) clock = pygame.time.Clock () fps = 30 screen_height = 520 screen_width = 650 screen = pygame.display.set_mode ((screen_width, screen_height)) Rect class (pygame.sprite.Sprite): def __init __ (self, width, height, color, value): super () .__ init __ () self.image = pygame.Surface ([width, height]) self.image.fill (color) self.rect = self.image.get_rect () self.value = value def change_value (self, color, value): self.image.fill (color) self.value = value rects = pygame.sprite.Group () rect = Rect (100,100, black, 1) rects.add (rect) while True for the event in pygame.event.get (): if event.type == pygame.QUIT: Finish() screen.fill (white) rect.draw (screen) pygame.display.flip () clock.tick (fps)
Why is this? How do I make a rectangle?
I am trying to render and save 8 rectangles that can be clicked to activate or deactivate them. I am trying to represent the lines as objects and then use their collision for mouse clicks.