python进行简单的ui制作_在Python中为文本冒险制作UI的最佳方法

我对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()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值