我正在制作一个角色扮演游戏,我的代码中有一个部分阻止我穿过墙壁。但是,如果我有钥匙,我只能输入一个门。
class Item:
def __init__(self,item,x,y,picture,owner):
self.item = item
self.x = x
self.y = y
self.picture = picture
self.owner = owner
Chart.chart.create_image(x,y,image=picture,anchor=NW)
def grab(i,h):
i.owner = h
def discard(i,h):
i.owner = None
class Move:
def checkwallup(x):
global up
global down
global left
global right
global xx
global yy
global marketwall
global castlewall
global bforest2
global bmarket
global bcastle
global bforest1
global forest1wall
global forest2wall
global cave
global cave1doorR
global cave1doorL
global bcave1
global cave1wall
global key1
global Key
global hero
# global treetop
yy = yy - 30
pos = (xx,yy)
if bmarket == True:
if pos in marketwall:
yy = yy + 30
Chart.chart.itemconfigure(x,image=heroupstand)
elif pos == (150,30):
if Key.owner == hero:
Move.moveup(x)
else:
Chart.chart.itemconfigure(x,image=heroupstand)
elif pos == (150,0):
if Key.owner == hero:
castle()
else:
Chart.chart.itemconfigure(x,image=heroupstand)
else:
Move.moveup(x)
当我走进大门时如果我按两次没有任何反应,但如果我按第三次,我会直接进入大门,好像我不需要按键。此外,当发生这种情况时,我行动中的其他一切开始变得混乱。