Add player creation; global clearScreen def; mainMenu to TitleScreen
This commit is contained in:
parent
7f4c180b23
commit
74244d953e
34
main.py
34
main.py
@ -1,6 +1,5 @@
|
||||
import os
|
||||
|
||||
PLAYER_NAME = "jack"
|
||||
PLAYER_INIT_LOCATION = "1"
|
||||
class Player:
|
||||
|
||||
@ -11,15 +10,18 @@ class Player:
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
def setName(self, name):
|
||||
self.name = name
|
||||
|
||||
def getLocation(self):
|
||||
return self.location
|
||||
|
||||
class GameManager:
|
||||
'Manage the game'
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, userInput):
|
||||
self.gameIsRunning = True
|
||||
self.player = Player(PLAYER_NAME, PLAYER_INIT_LOCATION)
|
||||
self.player = Player(userInput, PLAYER_INIT_LOCATION)
|
||||
|
||||
def isGameRunning(self):
|
||||
return self.gameIsRunning
|
||||
@ -32,13 +34,14 @@ class GameManager:
|
||||
print("Location: ", self.player.getLocation())
|
||||
print()
|
||||
|
||||
def clearScreen(self):
|
||||
os.system('clear')
|
||||
|
||||
def clearScreen():
|
||||
os.system('clear')
|
||||
|
||||
def mainMenu():
|
||||
def titleScreen():
|
||||
while(True):
|
||||
os.system('clear')
|
||||
clearScreen()
|
||||
print("Space Game Title To Be Disclosed!!!")
|
||||
userInput = input("(n)ew game (q)uit:\n>> ").lower()
|
||||
|
||||
if userInput == "q":
|
||||
@ -47,13 +50,17 @@ def mainMenu():
|
||||
if userInput == "n":
|
||||
mainGame()
|
||||
|
||||
|
||||
def mainGame():
|
||||
Game = GameManager()
|
||||
userInput = ""
|
||||
|
||||
userInput = input("What is your name... peasant?")
|
||||
|
||||
Game.clearScreen()
|
||||
if userInput == "":
|
||||
userInput = "(none)"
|
||||
|
||||
Game = GameManager(userInput)
|
||||
|
||||
clearScreen()
|
||||
|
||||
while Game.isGameRunning():
|
||||
userInput = input("(q)uit (p)layer stats (c)lear screen:\n>> ").lower()
|
||||
@ -65,12 +72,9 @@ def mainGame():
|
||||
Game.printPlayerStats()
|
||||
|
||||
if userInput == "c":
|
||||
Game.clearScreen()
|
||||
clearScreen()
|
||||
|
||||
def main():
|
||||
mainMenu()
|
||||
titleScreen()
|
||||
|
||||
main()
|
||||
# Main menu should be start game or quit
|
||||
# game running should be false until start
|
||||
# ending the game shoudl return to the main menu
|
||||
|
Loading…
x
Reference in New Issue
Block a user