-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass18.py
More file actions
29 lines (22 loc) · 766 Bytes
/
Class18.py
File metadata and controls
29 lines (22 loc) · 766 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
import pygame
pygame.init()
pygame.font.init()
width, height = 64*16,64*9
screen = pygame.display.set_mode((width,height))
#icon_x,icon_y = (screen.get_rect().center)
rect1 = pygame.Rect(*screen.get_rect().center, 0,0).inflate(100,100)
rect2 = pygame.Rect(0,0,75,75)
#icon = pygame.image.load("hero.png")
while True:
screen.fill((0,0,100))
#screen.blit(icon,(icon_x,icon_y))
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit(0)
rect2.center = pygame.mouse.get_pos()
collide = rect1.colliderect(rect2)
color = (250,0,0) if collide else (255,255,255)
pygame.draw.rect(screen,color,rect1)
pygame.draw.rect(screen,(0,255,0),rect2,4,1)
pygame.display.flip()