-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyCircleClass.py
More file actions
74 lines (55 loc) · 1.86 KB
/
Copy pathMyCircleClass.py
File metadata and controls
74 lines (55 loc) · 1.86 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import pygame
pygame.init()
screen = pygame.display.set_mode([500, 500])
red = (255 ,0, 0 )
green = (0, 255, 0)
blue = (0, 0, 255)
black = (0, 0, 0)
white = (255, 255, 255)
yellow = (255, 255, 0)
screen.fill(white)
class my_circle():
def __init__(self, color, pos, rad, wid = 0):
self.color = color
self.pos = pos
self.rad = rad
self.wid = wid
self.scrn = screen
def draw(self):
pygame.draw.circle(self.scrn, self.color, self.pos, self.rad, self.wid)
def grow(self, x):
self.rad += x
pygame.draw.circle(self.scrn, self.color, self.pos, self.rad, self.wid)
position = (300, 300)
radius = 50
wid = 2
pygame.draw.circle(screen, red, position, radius, wid)
pygame.display.update()
#creating instances
blue_circle = my_circle(blue, position, radius + 60)
red_circle = my_circle(red, position, radius + 40)
yellow_circle = my_circle(yellow, position, radius, 5)
green_circle = my_circle(green, position, 20)
running = True
while(running):
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for event in pygame.event.get():
if (event.type == pygame.MOUSEBUTTONDOWN):
blue_circle.draw()
red_circle.draw()
yellow_circle.draw()
green_circle.draw()
pygame.display.update()
elif (event.type == pygame.MOUSEBUTTONUP):
blue_circle.grow(2)
red_circle.grow(2)
yellow_circle.grow(2)
green_circle.grow(2)
pygame.display.update()
elif (event.type == pygame.MOUSEMOTION):
pos = pygame.mouse.get_pos()
black_circle = my_circle(black, pos, 5)
black_circle.draw()
pygame.display.update()