-
Notifications
You must be signed in to change notification settings - Fork 0
/
pygame-test-2.py
61 lines (55 loc) · 1.81 KB
/
pygame-test-2.py
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
57
58
59
60
61
# -*- coding: utf-8 -*-
print "début du programme..."
import pygame
from pygame.locals import *
import os
import time
# Before you can do much with pygame, you will need to initialize it
pygame.init()
clock = pygame.time.Clock()
def init_screen(taille, boolFS, nbColors):
return pygame.display.set_mode(taille,boolFS*FULLSCREEN, nbColors)
def main():
Fullscreen=False
screen = init_screen((640, 480), Fullscreen, 16)
pygame.display.set_caption("Hello !")
print(os.getcwd())
img2points = pygame.image.load("deux-points.jpg").convert()
digit=[]
for i in range(10):
digit.append(pygame.image.load(`i`+".jpg").convert())
loop = True
heure=""
while loop:
hh = "%02d:%02d:%02d"%(time.localtime()[3:6])
if heure != hh:
print "======================"
heure=hh
x = 240
y = 100
for c in list(heure):
if c==':':
screen.blit(img2points, (x, y))
x += img2points.get_width()
else:
screen.blit(digit[(ord(c)-ord('0')) % 10], (x, y))
x += digit[(ord(c)-ord('0')) % 10].get_width()
else:
print "."
for event in pygame.event.get():
if event.type == pygame.QUIT:
loop = False
if event.type == KEYDOWN:
if event.key == K_f:
Fullscreen = not Fullscreen
screen = init_screen((640, 480), Fullscreen, 16)
if event.key == K_q:
loop=False
print "touche frappée [%c]"%(event.key)
# Actualisation de l'affichage
pygame.display.update()
# 10 fps
clock.tick(1)
if __name__ == '__main__':
main()
print "fin du prg."