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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #!/usr/bin/python
# coding: utf-8
# try a turn counter with pygame
import sys, pygame
import spqr_defines as SPQR
from pygame.locals import *
def counter():
START_YEAR = -201
END_YEAR = 117
START_YEAR += 1
return START_YEAR
def main():
#iniatilize the window
pygame.init()
root = pygame.display.set_mode((400, 400))
pygame.display.set_caption("A simple turn counter test")
#background
background = pygame.Surface(root.get_size())
background = background.convert()
background.fill((250, 250, 250))
#text background
font = pygame.font.SysFont("Georgia", 36)
text = font.render('Click for past one turn:', 1, (10, 10, 10))
background.blit(text, (20, 20))
#text counter
font2 = pygame.font.SysFont("Georgia", 24)
text2 = font.render(str(counter()), 1, (10, 10, 10))
background.blit(text2, (220, 100))
#play button for starting a new date
playbutton = pygame.image.load("playbutton.png").convert()
iteration = playbutton.get_rect()
# je bloque à ce niveau
background.blit(playbutton, (150, 100))
#blit all on root
root.blit(background, (0, 0))
pygame.display.flip()
#event loop
while 1:
for event in pygame.event.get():
if event.type == QUIT:
return
root.blit(background, (0, 0))
pygame.display.flip()
if __name__ == '__main__': main() |
Partager