我正在使用Pygame,并且已经知道如何在屏幕上显示文本。但是我如何让它为一个变量工作,所以它不会显示“Hello”,而是显示我的变量。例如,假设我有一个变量,我想在显示面板上显示它/对它所做的任何更改。所以如果变量是1,并且添加了1,我想显示更改后的变量。
#Dice random number generation
diceRoll = random.randrange(0, 5)
#Text through GUI
myFont = pygame.font.SysFont("Times New Roman", 18)
randNumLabel = myFont.render("You have rolled:", 1, black)
diceDisplay = myFont.render(diceRoll, 1, black)
screen.blit(randNumLabel, (520, 20))
screen.blit(diceDisplay, (520, 30))
pygame.display.flip()
目前没有回答
相关问题 更多 >
编程相关推荐