-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamemenu.py
49 lines (35 loc) · 1.02 KB
/
gamemenu.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
# PyRPG
# File: gamemenu.py
# Version: 1.0
# Creator: Joel D. Garrett
# Modified: 3/2/2011
# Private Attributes
_kGameMenuLineLength = 80
class GameMenu:
# Attributes
title = "Menu"
options = {"Q" : "Quit Game"}
def printDivider(self):
divider = ""
length = _kGameMenuLineLength
while length > 0:
divider = divider + "-"
length -= 1
print "%s" % (divider)
def printTitle(self):
length = (_kGameMenuLineLength / 2) - (len(self.title) / 2)
padding = ""
while length > 0:
padding = padding + " "
length -= 1
print "%s%s" % (padding, self.title)
def captureUserInput(self):
print "User input not implemented by subclass"
return 0
def display(self):
self.printDivider()
self.printTitle()
self.printDivider()
for key, value in self.options.iteritems():
print " %s: %s" % (key, value)
return self.captureUserInput()