-1
私はPythonには新しく、古典的なテキストの冒険をしようとしています。現在、私の基本的なゲームはコマンドプロンプトで再生されます。PythonでテキストアドベンチャーのUIを作成する最善の方法
- が をに解釈される入力を集める下部の入力ボックスを持って
- 白地に大きな黒いフォントでゲームのテキストを印刷します: は、どのように私はシンプルなUIを作るに行きますか。 (コマンドプロンプトと同様)
本質的にZorkに似たUIです。 私は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()
面白そうに見えますが、一度チェックしてください!コマンドを入力するたびに、新しいテキストを画面に印刷するにはどうすればいいですか? –
私はあなたに今説明することはできません。オプションを入力する代わりにクリックするだけで、ボタンを作成することができます。まず、PyQt4の基本を学ばなければならないし、基本的なことについてはGoogleから助けを得ることができます。 :) ご希望の場合は、正しい答えをマークしてください。 –