1
+ import pygame
2
+ import time
3
+
4
+ pygame .init ()
5
+
6
+
7
+ display_width = 800
8
+ display_height = 480
9
+
10
+ gameDisplay = pygame .display .set_mode ((display_width ,display_height ), pygame .FULLSCREEN )
11
+ #gameDisplay = pygame.display.set_mode((display_width,display_height))
12
+ pygame .display .set_caption ('Nixie Clock' )
13
+ pygame .mouse .set_visible (0 )
14
+
15
+ black = (0 ,0 ,0 )
16
+ white = (255 ,255 ,255 )
17
+
18
+ clock = pygame .time .Clock ()
19
+ crashed = False
20
+
21
+ Img0 = pygame .image .load ('Nixie0.png' )
22
+ Img1 = pygame .image .load ('Nixie1.png' )
23
+ Img2 = pygame .image .load ('Nixie2.png' )
24
+ Img3 = pygame .image .load ('Nixie3.png' )
25
+ Img4 = pygame .image .load ('Nixie4.png' )
26
+ Img5 = pygame .image .load ('Nixie5.png' )
27
+ Img6 = pygame .image .load ('Nixie6.png' )
28
+ Img7 = pygame .image .load ('Nixie7.png' )
29
+ Img8 = pygame .image .load ('Nixie8.png' )
30
+ Img9 = pygame .image .load ('Nixie9.png' )
31
+ Imgdot = pygame .image .load ('Neon.png' )
32
+
33
+
34
+
35
+ def digit (x ,y ,z ):
36
+ if z == 0 :
37
+ gameDisplay .blit (Img0 , (x ,y ))
38
+ if z == 1 :
39
+ gameDisplay .blit (Img1 , (x ,y ))
40
+ if z == 2 :
41
+ gameDisplay .blit (Img2 , (x ,y ))
42
+ if z == 3 :
43
+ gameDisplay .blit (Img3 , (x ,y ))
44
+ if z == 4 :
45
+ gameDisplay .blit (Img4 , (x ,y ))
46
+ if z == 5 :
47
+ gameDisplay .blit (Img5 , (x ,y ))
48
+ if z == 6 :
49
+ gameDisplay .blit (Img6 , (x ,y ))
50
+ if z == 7 :
51
+ gameDisplay .blit (Img7 , (x ,y ))
52
+ if z == 8 :
53
+ gameDisplay .blit (Img8 , (x ,y ))
54
+ if z == 9 :
55
+ gameDisplay .blit (Img9 , (x ,y ))
56
+ if z == 10 :
57
+ gameDisplay .blit (Imgdot , (x ,y ))
58
+
59
+
60
+ y = 150
61
+ c = 0
62
+ ml = 0
63
+ bl = 0
64
+ while not crashed :
65
+ for event in pygame .event .get ():
66
+ if event .type == pygame .QUIT :
67
+ crashed = True
68
+
69
+
70
+ clock .tick (60 )
71
+ c = c + 1
72
+ if c >= 60 :
73
+ c = 0
74
+ bl = ~ bl
75
+ gameDisplay .fill (black )
76
+
77
+ result = time .localtime ()
78
+
79
+ digit (0 ,y , result .tm_hour // 10 )
80
+ digit (200 ,y ,result .tm_hour % 10 )
81
+
82
+ digit (400 ,y , result .tm_min // 10 )
83
+ digit (600 ,y , result .tm_min % 10 )
84
+ if bl == 0 :
85
+ digit (395 ,y + 140 , 10 )
86
+
87
+ pygame .display .update ()
88
+
89
+
90
+
91
+ pygame .quit ()
92
+ quit ()
0 commit comments