-
Notifications
You must be signed in to change notification settings - Fork 94
/
menu.py
81 lines (71 loc) · 2.52 KB
/
menu.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
import subprocess
import os
running = True
state = 0
def printHeader():
os.system('clear')
print 'S N A K E\n'
def tutorial():
global state
if state == 0:
printHeader()
print '\nHi there! Welcome to Snake.'
print 'Type snake to launch the game'
success = False
while not success:
command = raw_input()
if command == 'snake':
print '\nUse the keys to move and Q to quit'
subprocess.call("sleep 1", shell=True)
print '3...'
subprocess.call("sleep 1", shell=True)
print '2...'
subprocess.call("sleep 1", shell=True)
print '1...'
subprocess.call("sleep 1", shell=True)
subprocess.call("python __main__.py", shell=True)
success = True
state += 1
else:
print 'Type snake to launch the game'
elif state == 1:
printHeader()
print 'Great game. Now let\'s see what options are available.'
print 'Type snake --help'
success = False
while not success:
command = raw_input()
if command == 'snake --help' or command == 'snake -h':
subprocess.call("python . --help", shell=True)
subprocess.call("sleep 1", shell=True)
success = True
state += 1
else:
print 'Type snake --help'
elif state == 2:
print '\n\nYou can try different themes for the game'
print 'For example, type snake --theme minimal'
print 'Or type snake --help to get a list of available themes and then snake --theme "name"'
success = False
while not success:
command = raw_input()
cmdArray = command.split(' ')
if len(cmdArray) == 3 and \
cmdArray[0] == 'snake --theme' and \
cmdArray[1] == '--theme' or cmdArray[1] == '--t' and \
cmdArray[2] == 'classic' or cmdArray[2] == 'minimal':
command = "python . --theme " + cmdArray[2]
subprocess.call(command, shell=True)
success = True
state += 1
elif command == 'snake --help' or command == 'snake -h':
success = False
else:
print 'Try typying snake --theme minimal'
def run():
try:
while running:
tutorial()
except KeyboardInterrupt:
exit()
run()