Add player creation; global clearScreen def; mainMenu to TitleScreen
This commit is contained in:
parent
7f4c180b23
commit
74244d953e
36
main.py
36
main.py
@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
PLAYER_NAME = "jack"
|
|
||||||
PLAYER_INIT_LOCATION = "1"
|
PLAYER_INIT_LOCATION = "1"
|
||||||
class Player:
|
class Player:
|
||||||
|
|
||||||
@ -11,15 +10,18 @@ class Player:
|
|||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def setName(self, name):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
def getLocation(self):
|
def getLocation(self):
|
||||||
return self.location
|
return self.location
|
||||||
|
|
||||||
class GameManager:
|
class GameManager:
|
||||||
'Manage the game'
|
'Manage the game'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, userInput):
|
||||||
self.gameIsRunning = True
|
self.gameIsRunning = True
|
||||||
self.player = Player(PLAYER_NAME, PLAYER_INIT_LOCATION)
|
self.player = Player(userInput, PLAYER_INIT_LOCATION)
|
||||||
|
|
||||||
def isGameRunning(self):
|
def isGameRunning(self):
|
||||||
return self.gameIsRunning
|
return self.gameIsRunning
|
||||||
@ -32,13 +34,14 @@ class GameManager:
|
|||||||
print("Location: ", self.player.getLocation())
|
print("Location: ", self.player.getLocation())
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def clearScreen(self):
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
|
def clearScreen():
|
||||||
|
os.system('clear')
|
||||||
|
|
||||||
def mainMenu():
|
def titleScreen():
|
||||||
while(True):
|
while(True):
|
||||||
os.system('clear')
|
clearScreen()
|
||||||
|
print("Space Game Title To Be Disclosed!!!")
|
||||||
userInput = input("(n)ew game (q)uit:\n>> ").lower()
|
userInput = input("(n)ew game (q)uit:\n>> ").lower()
|
||||||
|
|
||||||
if userInput == "q":
|
if userInput == "q":
|
||||||
@ -46,14 +49,18 @@ def mainMenu():
|
|||||||
|
|
||||||
if userInput == "n":
|
if userInput == "n":
|
||||||
mainGame()
|
mainGame()
|
||||||
|
|
||||||
|
|
||||||
def mainGame():
|
def mainGame():
|
||||||
Game = GameManager()
|
|
||||||
userInput = ""
|
userInput = ""
|
||||||
|
|
||||||
|
userInput = input("What is your name... peasant?")
|
||||||
|
|
||||||
|
if userInput == "":
|
||||||
|
userInput = "(none)"
|
||||||
|
|
||||||
|
Game = GameManager(userInput)
|
||||||
|
|
||||||
|
clearScreen()
|
||||||
Game.clearScreen()
|
|
||||||
|
|
||||||
while Game.isGameRunning():
|
while Game.isGameRunning():
|
||||||
userInput = input("(q)uit (p)layer stats (c)lear screen:\n>> ").lower()
|
userInput = input("(q)uit (p)layer stats (c)lear screen:\n>> ").lower()
|
||||||
@ -65,12 +72,9 @@ def mainGame():
|
|||||||
Game.printPlayerStats()
|
Game.printPlayerStats()
|
||||||
|
|
||||||
if userInput == "c":
|
if userInput == "c":
|
||||||
Game.clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
mainMenu()
|
titleScreen()
|
||||||
|
|
||||||
main()
|
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