-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle_Class.py
More file actions
36 lines (28 loc) · 873 Bytes
/
Copy pathRectangle_Class.py
File metadata and controls
36 lines (28 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame
pygame.init()
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
screen = pygame.display.set_mode((600, 600))
screen.fill(BLACK)
pygame.display.update()
class rectangle():
def __init__(self, color, dimensions):
self.rect_surf = screen
self.rect_dimensions = dimensions
self.rect_color = color
def draw(self):
self.Draw_Rect = pygame.draw.rect(self.rect_surf, self.rect_color, self.rect_dimensions)
RED_rect = rectangle(RED, (50, 20, 120, 75))
GREEN_rect = rectangle(GREEN, (150, 200, 175, 100))
BLUE_rect = rectangle(BLUE, (300, 400, 200, 120))
RED_rect.draw()
BLUE_rect.draw()
GREEN_rect.draw()
pygame.display.update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False