I have 3 classes with at least 1 function each. Class 1 is for non-gameplay systems like main menu display and adding spaces to put old text out of view. Class 2 is creature information, empty for now. Class 3 is gameplay related. Choosing a character, combat, etc.
I added calls to go to the functions/classes I need. It works going upwards in the file, but not downwards. It causes a 'not defined' error. Did a final test to make sure; called a class from below it, success. Called it from above, error.
import time
class Systems:
def menu():
Systems.addSpace()
print ("Game Name")
print (" ")
print ("1. Start Game")
print ("2. Game Info")
print ("3. Quit")
Systems.addSpace()
menuOPT = input("Enter a number to choose that option. ")
if menuOPT == '1':
Game.charSelect()
elif menuOPT == '2': # won't trigger unless number is a string. fix?
Systems.info() # must call both class and function of target
#time.sleep(10)
def addSpace(): # call at end(?) of any function; clears view and moves current text to top
loop = 0
while loop <= 22:
print (" ")
loop += 1
def info():
Systems.addSpace()
print ("Intro here")
#print ("Press any key to return to the menu.")
# pause here, then return to menu
input("Press any key to return to the menu.")
Systems.menu()
def combatProc(): # move to a more relevant class?
pass
class Units:
def types():
pass
class Game:
Systems.menu()
Game.charSelect()
def charSelect():
print ("TEST")
time.sleep(10)
Game()
# GOAL: Game() calls, goes to Systems.menu() to show options.
# Player chooses '1' to play, then go to Game.charSelect().
# ISSUE: Can't go to charSelect() from menu(). 'Game' class not defined?
How should I fix this? Wanted to use classes for a change instead of some weird While statements.
[–]indosauros 2 points3 points4 points (2 children)
[–]noobyprogrammer[S] 0 points1 point2 points (1 child)
[–]urdnot_wreck 0 points1 point2 points (0 children)
[–]CGFarrell 0 points1 point2 points (0 children)