-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6dice.py
110 lines (90 loc) · 2.78 KB
/
6dice.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# 6 Sided die - graphic display = press X for next number
from random import randint # import random integer function
import pew # Import pewpew library
pew.init() # Initlise library
screen = pew.Pix() # Create blsnk screen
# Define pattern for 1 dot
score1 = pew.Pix.from_iter((
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
))
# Define pattern for 2 dots
score2 = pew.Pix.from_iter((
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 1, 1, 0, 0, 0, 0, 0),
(0, 1, 1, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 1, 1, 0),
(0, 0, 0, 0, 0, 1, 1, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
))
# Define pattern for 3 dots
score3 = pew.Pix.from_iter((
(1, 1, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 1, 1),
(0, 0, 0, 0, 0, 0, 1, 1),
))
# Define pattern for 4 dots
score4 = pew.Pix.from_iter((
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
))
# Define pattern for 5 dots
score5 = pew.Pix.from_iter((
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
(0, 0, 0, 0, 0, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 1, 1, 0, 0, 0),
(0, 0, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
))
# Define pattern for 6 dots
score6 = pew.Pix.from_iter((
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
(0, 0, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
(0, 0, 0, 0, 0, 0, 0, 0),
(1, 1, 0, 0, 0, 0, 1, 1),
(1, 1, 0, 0, 0, 0, 1, 1),
))
while True:
pew.tick(1) # pause 1 second
key = pew.keys() # read key press
if key & pew.K_X: # if X key pressed...
dice = randint(1, 6) # Pick random integer from 1 to 6
if dice == 1:
screen.blit(score1) # if ==1 choose 1 dot pattern
elif dice == 2:
screen.blit(score2) # if ==2 choose 2 dot pattern
elif dice == 3:
screen.blit(score3) # if ==3 choose 3 dot pattern
elif dice == 4:
screen.blit(score4) # if ==4 choose 4 dot pattern
elif dice == 5:
screen.blit(score5) # if ==5 choose 5 dot pattern
elif dice == 6:
screen.blit(score6) # if ==6 choose 6 dot pattern
pew.show(screen) # Display Screen content
pew.tick(1) # Pause 1 Second