43 lines
1008 B
Python
Executable File
43 lines
1008 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import sys, pygame
|
|
pygame.init()
|
|
|
|
infos = pygame.display.Info()
|
|
# size = infos.current_w, infos.current_h
|
|
size = 1024, 768
|
|
background = 255, 255, 255
|
|
|
|
screen = pygame.display.set_mode(size)
|
|
|
|
screen.fill(background)
|
|
|
|
button = pygame.Rect(200, 200, 50, 50)
|
|
screen.fill((0,0,0), rect=button)
|
|
|
|
button2 = pygame.Rect(400, 200, 50, 50)
|
|
screen.fill((0,0,0), rect=button2)
|
|
|
|
pygame.display.flip()
|
|
|
|
i = 0
|
|
|
|
font = pygame.font.Font(None, 80)
|
|
|
|
while True:
|
|
for event in pygame.event.get():
|
|
if event.type in (pygame.QUIT, pygame.KEYDOWN):
|
|
sys.exit()
|
|
elif event.type == pygame.MOUSEBUTTONUP:
|
|
if button.collidepoint(pygame.mouse.get_pos()):
|
|
i += 1
|
|
if button2.collidepoint(pygame.mouse.get_pos()):
|
|
i -= 1
|
|
|
|
text = str(i)
|
|
size = font.size(text)
|
|
ren = font.render(text, 0, (0, 0, 0))
|
|
screen.fill(background, rect=((10,10),size))
|
|
screen.blit(ren, (10, 10))
|
|
pygame.display.update(((10,10),size))
|