python - Global Function block? -
i making game in python. whenever want in game, type help , can read section.
the problem is, need add function block each level.
def level_01(): choice = raw_input('>>>: ') if choice=='help': level_01_help() def level_012(): choice = raw_input('>>>: ') if choice=='help': level_02_help()
so wondering if possible make global function block levels? when enter help, help(), , automatically goes function block came from.
i hope understand mean, , appreciate get.
you can pass function paramater, meaning code can become:
def get_choice(help_func): choice = raw_input('>>>: ') if choice == 'help': help_func() else: return choice def level_01(): choice = get_choice(level_01_help) def level_02(): choice = get_choice(level_02_help)
ideally should have separate module interface related tasks, game , interface 2 seperate entities. should make 2911 lines bit more legible, , if decide change interfaces (from command line tkinter or pygame example) have much easier time of it. 2¢
Comments
Post a Comment