commit 9a955a4b0455c6299a6b12e6295ed02b9e0d2ace Author: Guillaume Dott Date: Thu Sep 21 11:38:03 2017 +0200 Test some things with pygame diff --git a/photoboite.py b/photoboite.py new file mode 100755 index 0000000..22162d4 --- /dev/null +++ b/photoboite.py @@ -0,0 +1,42 @@ +#!/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))