-
Notifications
You must be signed in to change notification settings - Fork 0
/
code secret.py
164 lines (146 loc) · 3.63 KB
/
code secret.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def code_secret():
##### Libraries #####
from sense_hat import SenseHat
from time import sleep
import random
##### Functions #####
def Secousses():
o=1
while o==1:
x, y, z = sense.get_accelerometer_raw().values()
x = abs(x)
y = abs(y)
z = abs(z)
if x > 3 or y > 3 or z > 3:
o=2
def Pression():
test=True
while test:
o=sense.get_pressure()
if int(o)>994:
test=False
def Sens():
pause = 3
score = 0
angle = 0
go = True
while go:
angle2 = angle
while angle == angle2:
angle = random.choice([0, 90, 180, 270])
sense.set_rotation(angle)
sense.set_pixels(fleche)
sleep(pause)
x, y, z = sense.get_accelerometer_raw().values()
x = round(x, 0)
y = round(y, 0)
if x == -1 and angle == 180:
sense.set_pixels(fleche)
score += 1
elif x == 1 and angle == 0:
sense.set_pixels(fleche)
score += 1
elif y == -1 and angle == 90:
sense.set_pixels(fleche)
score += 1
elif y == 1 and angle == 270:
sense.set_pixels(fleche)
score += 1
else:
go = False
sense.show_message("Voleur!")
input()
if score == 5:
go = False
sleep(0.5)
def Verrous():
sense.clear([0, 0, 0])
sense.show_letter("1")
sleep(1)
sense.set_pixels(locked)
Secousses()
sense.clear([0 ,0 ,0])
sense.show_letter("2")
sleep(1)
sense.set_pixels(locked)
Pression()
sense.clear([0 ,0 ,0])
sense.show_letter("3")
sleep(1)
sense.set_pixels(locked)
Sens()
##### Pixel Art #####
r = (255, 0, 0)
g = (0, 255, 0)
w = (255, 255, 255)
e = (0, 0, 0)
j = (255,255,0)
m = (100,100,100)
locked = [
e,e,e,e,e,e,e,e,
e,e,e,w,w,e,e,e,
e,e,w,e,e,w,e,e,
e,e,w,e,e,w,e,e,
e,e,r,r,r,r,e,e,
e,e,r,r,r,r,e,e,
e,e,r,r,r,r,e,e,
e,e,e,e,e,e,e,e
]
unlocked = [
e,e,e,e,e,e,e,e,
e,e,e,e,e,w,w,e,
e,e,e,e,w,e,e,w,
e,e,e,e,w,e,e,w,
e,e,g,g,g,g,e,e,
e,e,g,g,g,g,e,e,
e,e,g,g,g,g,e,e,
e,e,e,e,e,e,e,e
]
fleche = [
e,e,e,e,e,e,e,e,
e,e,e,r,r,e,e,e,
e,e,r,r,r,r,e,e,
e,e,e,r,r,e,e,e,
e,e,e,r,r,e,e,e,
e,e,e,r,r,e,e,e,
e,e,e,r,r,e,e,e,
e,e,e,e,e,e,e,e,
]
coffre = [
e,e,e,e,e,e,e,e,
e,e,e,e,e,e,e,e,
e,e,e,j,j,e,e,e,
e,e,j,j,j,j,e,e,
e,j,m,m,m,m,j,e,
e,e,m,m,m,m,e,e,
e,j,m,m,m,m,j,e,
e,e,e,e,e,e,e,e,
]
coffre2 = [
e,e,e,e,e,e,e,e,
e,e,e,e,e,e,e,e,
e,e,e,j,j,e,e,e,
e,e,j,j,j,j,e,e,
e,e,m,m,m,m,e,e,
e,j,m,m,m,m,j,e,
e,e,m,m,m,m,e,e,
e,e,e,e,e,e,e,e,
]
#### Programme principal ####
sense=SenseHat()
sense.set_pixels(locked)
sleep(2)
##### Locks #####
Verrous()
##### Unlocked #####
sense.set_pixels(unlocked)
sleep(2)
sense.show_message("Vous avez trouves le tresor !",scroll_speed=0.1,text_colour=(255,0,0),back_colour=(0,0,255))
boucle = 1
while not boucle == 5 :
sense.set_pixels(coffre)
sleep(0.3)
sense.set_pixels(coffre2)
sleep(0.3)
boucle = boucle + 1
sense.clear()