#!/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_size = int(screen.get_width() / 4) button_up = pygame.image.load('button-up.png').convert_alpha() button_up = pygame.transform.smoothscale(button_up, (button_size, button_size)) button_down = pygame.image.load('button-down.png').convert_alpha() button_down = pygame.transform.smoothscale(button_down, (button_size, button_size)) button_up_rect = button_up.get_rect() button_up_rect.topleft = screen.get_width() - button_size - 20, screen.get_height() / 2 - button_size / 2 button2 = pygame.Rect(screen.get_width() - 70, 100, 50, 50) camera = pygame.Rect(20, 20, screen.get_width() - screen.get_width() / 4 - 60, screen.get_height() - 40) font = pygame.font.Font(None, 80) i = 0 pressed = False while True: for event in pygame.event.get(): if event.type in (pygame.QUIT, pygame.KEYDOWN): sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if button_up_rect.collidepoint(pygame.mouse.get_pos()): pressed = True elif event.type == pygame.MOUSEBUTTONUP: if button_up_rect.collidepoint(pygame.mouse.get_pos()): pressed = False i += 1 if button2.collidepoint(pygame.mouse.get_pos()): i -= 1 screen.fill(background) screen.fill((0,0,0), rect=button2) screen.fill((0,0,0), rect=camera) text = str(i) size = font.size(text) ren = font.render(text, 0, (255, 255, 0)) screen.blit(ren, (40, 40)) if pressed: screen.blit(button_down, button_up_rect) else: screen.blit(button_up, button_up_rect) pygame.display.flip()