From c58efad369f4e94d7eb28bae0bee8bb9a0d8fe6d Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Mon, 10 May 2021 19:27:43 -0400 Subject: [PATCH] Pretty up the menus a bit --- main.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 051475f..7a09c83 100644 --- a/main.py +++ b/main.py @@ -32,19 +32,25 @@ class GameManager: self.gameIsRunning = False def printPlayerStats(self): + clearScreen() print("Name: ", self.player.getName()) print("Location: ", self.player.getLocation()) print() def enterTradeHub(self): + clearScreen() while True: - userInput = input("(l)ist items (e)xit\n>> ").lower() + userInput = input("(e)xit\n\n(l)ist items\n>> ").lower() if userInput == 'e': + clearScreen() break; - if userInput == 'l': + elif userInput == 'l': + clearScreen() self.planets[self.player.getLocation()].getTradeHub().printItems() + else: + clearScreen() class Planet: 'Contains trade hub' @@ -66,7 +72,8 @@ class TradeHub: def getItems(self): return self.items def printItems(self): - print(f"{'Name' : <15}{'* * * * * | * * * * *' : ^10}{'Cost' : >6}") + print(f"{'Name' : <15}{'- - - - - | - - - - -' : ^10}{'Cost' : >6}") + print() for item in self.items.values(): print(f"{item.getName() : <15}{'* * * * * | * * * * *' : ^10}{str(item.getPrice()) : >5}") print() @@ -89,7 +96,7 @@ def titleScreen(): while(True): clearScreen() print("Space Game Title To Be Disclosed!!!") - userInput = input("(n)ew game (q)uit:\n>> ").lower() + userInput = input("(n)ew game\n(q)uit:\n>> ").lower() if userInput == "q": break @@ -98,6 +105,7 @@ def titleScreen(): mainGame() def mainGame(): + clearScreen() tradeableItems = { "flour" : Item("flour", 0.5), "Rice Cakes" : Item("Rice Cakes", 1), @@ -140,18 +148,21 @@ def mainGame(): clearScreen() while Game.isGameRunning(): - userInput = input("(q)uit (p)layer stats (e)nter trade hub (c)lear screen:\n>> ").lower() + userInput = "" + userInput = input("(q)uit\n\n(p)layer stats\n(e)nter trade hub\n(c)lear screen:\n>> ").lower() if userInput == "q": Game.stopGame() - if userInput == "p": + elif userInput == "p": Game.printPlayerStats() - if userInput == "c": + elif userInput == "c": clearScreen() - if userInput == "e": + elif userInput == "e": Game.enterTradeHub() + else: + clearScreen() def main(): titleScreen()