-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed_the_kitty.py
136 lines (98 loc) · 4.68 KB
/
feed_the_kitty.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
"""
Rohan Shah
Click anywhere to add food to the plate
Enough food will make the cat happy
Cat's eyes will follow as mouse moves
"""
import pygame
pygame.init()
screen = pygame.display.set_mode((400, 400), 0, 32)
font = pygame.font.Font('freesansbold.ttf', 25)
print("DIRECTIONS:")
print("Click to feed cat")
print('eyes follow the food')
foodPileWidth = 10
foodPileHeight = 5
foodX = 200
foodY = 30
tearsVisible = True
leftEyeX = 165
leftEyeY = 185
rightEyeX = 235
rightEyeY = 185
messageValue = 'pleeeease'
while True:
screen.fill((170, 185, 55))
pygame.draw.circle(screen, (255, 255, 255), (200, 200), 150)
# ears
pygame.draw.polygon(screen, (53, 31, 22), ((261, 158), (305, 132), (280, 195)))
pygame.draw.polygon(screen, (145, 170, 110), ((290, 147), (280, 178), (270, 158)))
pygame.draw.polygon(screen, (53, 31, 22), ((139, 158), (95, 132), (120, 195)))
pygame.draw.polygon(screen, (145, 170, 110), ((108, 147), (128, 157), (120, 177)))
pygame.draw.polygon(screen, (55, 30, 20), ((227, 129), (305, 133), (264, 160)))
pygame.draw.polygon(screen, (0,0,0), ((285, 140), (265, 153), (250, 137)))
pygame.draw.polygon(screen, (55, 30, 20), ((173, 129), (95, 133), (136, 160)))
pygame.draw.polygon(screen, (0,0,0), ((115, 140), (138, 153), (150, 137)))
# face and body
pygame.draw.ellipse(screen, (55, 30, 20), (200-60, 276-65, 120, 130))
"""
FORMULA FOR ELLIPSE BORDERS
CENTERX + BORDERWIDTH - SIZEX/2
CENTERY + BORDERWIDTH - SIZEY/2
SIZEX - BORDERWIDTH *2
SIZEY - BORDERWIDTH *2"""
pygame.draw.ellipse(screen, (0,0,0), (206-60, 282-65, 120-12, 130-12))
pygame.draw.circle(screen, (55, 30, 20), (200, 200), 80)
pygame.draw.circle(screen, (0,0,0), (200, 200), 80-8)
# plate 245, 245, 220)
pygame.draw.ellipse(screen, (55, 30, 20), (200-70, 323-45//2, 140, 45))
pygame.draw.ellipse(screen, (245, 245, 220),(203-70, 326-45//2, 140 - 6, 45-6))
pygame.draw.ellipse(screen, (55, 30, 20), (200 - 100, 312 - 25, 200, 50))
pygame.draw.ellipse(screen, (255, 255, 255), (204 - 100, 316 - 25, 200 - 8, 50 - 8))
pygame.draw.ellipse(screen, (170, 185, 55), (200 - 150//2, 317 - 15, 150, 30), 3)
# hands
pygame.draw.ellipse(screen, (55, 30, 20), (165-15, 285-35//2, 30, 35))
pygame.draw.ellipse(screen, (0,0,0), (170-15, 290-35//2, 30 - 10, 35 - 10))
pygame.draw.ellipse(screen, (55, 30, 20), (235-15, 285-35//2, 30, 35))
pygame.draw.ellipse(screen, (0,0,0), (240-15, 290-35//2, 30-10, 35-10))
# eyes and tears
pygame.draw.ellipse(screen, (245, 245, 220), (163-75//2, 193-50, 75, 100))
pygame.draw.ellipse(screen, (245, 245, 220), (237-75//2, 193-50, 75, 100))
pygame.draw.ellipse(screen, (55, 30, 20), (leftEyeX-45//2, leftEyeY-55//2, 45, 55))
pygame.draw.ellipse(screen, (0,0,0), ((leftEyeX+4) - 45//2, (leftEyeY+4) - 55//2, 45-8, 55-8))
pygame.draw.ellipse(screen, (55, 30, 20), (rightEyeX-45//2, rightEyeY-55//2, 45, 55))
pygame.draw.ellipse(screen, (0,0,0), ((rightEyeX+4) - 45//2, (rightEyeY+4) - 55//2, 45-8, 55-8))
if tearsVisible: # 224, 255, 255
pygame.draw.ellipse(screen, (85, 130, 125), (150-25//2, 240-15//2, 25, 15))
pygame.draw.ellipse(screen, (224, 255, 255), (152-25//2, 242 - 15//2, 25-4, 15-4))
pygame.draw.ellipse(screen, (85, 130, 125), (250-25//2, 240-15//2, 25, 15))
pygame.draw.ellipse(screen, (224, 255, 255), (252-25//2, 242 - 15//2, 25-4, 15-4))
# message
message_text = font.render(messageValue, True, (170, 185, 55))
message_rect = message_text.get_rect()
message_rect.center = (200, 90)
screen.blit(message_text, message_rect)
# food
pygame.draw.ellipse(screen, (255, 160, 122), (210-foodPileWidth//2, 315-foodPileHeight//2, foodPileWidth, foodPileHeight))
pygame.draw.circle(screen, (0,0,0), (foodX, foodY), 10)
pygame.draw.circle(screen,(255, 160, 122), (foodX, foodY), 6)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN:
if foodPileHeight < 30:
foodPileWidth += 5
foodPileHeight += 2
if foodPileHeight >= 30:
messageValue = 'meow'
tearsVisible = False
if event.type == pygame.MOUSEMOTION:
pos = pygame.mouse.get_pos()
foodX = pos[0]
foodY = pos[1]
# represents CENTER of shape
leftEyeX = 155 + (pos[0] / 20)
leftEyeY = 180 + (pos[1] / 20)
rightEyeX = 225 + (pos[0] / 20)
rightEyeY = 180 + (pos[1] / 20)
pygame.display.update()