-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimon.py
More file actions
51 lines (46 loc) · 1.06 KB
/
simon.py
File metadata and controls
51 lines (46 loc) · 1.06 KB
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
import random
import time
def sort_key(value):
if (value == 1):
return 'w'
if (value == 2):
return 'a'
if (value == 3):
return 's'
if (value == 4):
return 'd'
if __name__ == '__main__':
pressed = 'a'
blinks = 1
to_press = []
finish = False
while(pressed != 'q' and pressed != 'Q'):
try:
pressed = input("Press q or Q to start! ")
except:
print ("EOF Error")
finish = True
break
while(finish == False):
print("Press q or Q to end game!")
print("=====================================================================")
for i in range(blinks):
to_press.append(sort_key(random.randint(1,4)))
print(to_press[i], end='\r')
time.sleep(0.5)
print(' ', end = '\r')
time.sleep(0.2)
j = 0
for i in range(blinks):
pressed = input("Press next button: ")
if (pressed != to_press[j] or pressed == 'q' or pressed == 'Q'):
finish = True
print("Game Over")
print("=====================================================================")
break
else:
j += 1
else:
print('Next stage')
to_press = []
blinks += 1