From 9a955a4b0455c6299a6b12e6295ed02b9e0d2ace Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Thu, 21 Sep 2017 11:38:03 +0200 Subject: [PATCH] Test some things with pygame --- photoboite.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 photoboite.py 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))