我对python非常陌生,我正在尝试一个经典的文本冒险。目前我的基本游戏只是在命令提示符下玩。
如何制作一个简单的用户界面:在白色背景上以黑色大字体打印游戏文本
底部有一个输入框,用于收集
解释。(类似于命令提示符)
基本上是一个类似于佐克的用户界面。
我试着用tkinter,但结果弄糊涂了,效率低下。另外,如果您想知道的话,我宁愿不使用命令提示符,因为文本非常小,我很难阅读。在
如果有帮助的话,以下是主要的游戏代码:from player import Player
#intro screen
def intro():
print('Incarnation')
print('''
Welcome to Incarnation, please type an option:
- Play
- Load
- Instructions
- Credits
- Quit
''')
option = input('>').lower()
if option == 'play':
play()
elif option == 'instructions':
print("""
Objective: The objective of the game is to complete the narrative by exploring
the world, collecting items, defeating enemies and solving puzzles.
You control your character by typing commands.
Here are some essential commands, make sure to experiment! They are not case sensitive.
N, S, E, W: Move your character in the cardinal directions
I: Open your inventory
H: Heal with an item in your inventory
A *item*: Attack with an item. Replace *item* with the name of the item.
T *NPC*: Talk to a present NPC. Repalce *NPC* with the name of the person.
""")
elif option == 'credits':
print('made by Lilian Wang')
elif option == 'load':
pass
elif option == 'quit':
quit()
else:
print("That's not an option.")
player = Player()
# Possible player actions
def actions(action):
if action == 'n':
player.move_north()
elif action == 's':
player.move_south()
elif action == 'e':
player.move_east()
elif action == 'w':
player.move_west()
elif 'heal' in str(action):
player.heal(action)
else:
print("You can't do that.")
player.previousLocation = player.location
# Main game function
def play():
print(player.location.name)
while player.gameover == False:
if player.previousLocation != player.location:
print(player.location.name)
action = input(">")
actions(action)
intro()