这是我第二次尝试使其生效。几天前,我在这个项目上发布了一个相当糟糕的问题,可以在这里看到:can i somehow import this into another file and combine with pygame?
但是我被正确告知我缩小问题范围,所以去:
我为二十一点游戏编写了一个python脚本,并且该游戏的逻辑运行正常,但是,我现在正尝试使用Pygame向其中添加GUI。 我正在集中精力展示玩家的纸牌,然后我将处理发牌人的纸牌以及其后的正确位置(否则错吗?)。
from BLACKJACKIMPORTtobeusedwithplayerclass import *
pygame.init()
## THIS IS A DICT OF DICTS THAT CONTAIN THE LOADED OBJECT OF ALL CARD PNG
FILES
cardpngs={'SUIT':{'RANK':pygame.image.load(PNG FILEPATH)}...........}
##
display_W = 800
display_H = 600
back_ground = pygame.image.load('tablesmall.png')
myhand=hand(100)
def start_game():
gameExit = False
while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
gameExit=True
gameDisplay = pygame.display.set_mode((display_W, display_H))
pygame.display.set_caption('BlackJack')
gameDisplay.blit(back_ground,(1,1))
##x and y position of card
xy = 1
'''playhand is a method of hand class that plays the hand without
gui
however when i put it in here the GUI completely stops working
even
though the game still works fine in the terminal
thats why the next line is commented out
'''
#myhand.playhand()
for i in myhand.contents:
gameDisplay.blit((cardpngs[i.suit][i.rank]),(xy,xy))
xy+=30
pygame.display.update()
我的脚本显示的背景很好,并显示了手的前两张牌,但是随着游戏的进行,我无法让它显示更多内容(请阅读有关hand.play()方法的代码中的注释)
感谢您抽出时间阅读我的问题。任何建议将不胜感激。