私は助けが必要です。私のコードはPygameで動いていません。表示されているのはすべて空白の画面です。私のコードはあなたに数字を尋ねるはずです。それを入力すると、コードはその数字を3の累乗で表示します。ここに私のコードは次のとおりです。Pygameのコードが動作していません
import pygame
import time
pygame.font.init()
pygame.init
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Cube')
gameExit = False
clock = pygame.time.Clock()
font = pygame.font.SysFont('arial', 25)
def message_to_screen(msg,color):
screen_text = font.render(msg, True, color)
gameDisplay.blit(screen_text, [display_width/2, display_height/2])
while not gameExit:
def input(number):
message_to_screen("Enter a Number to Cube")
total = number ** 3
if number > 0:
message_to_screen(total, red)
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True
gameDisplay.fill(white)
pygame.display.update()
time.sleep(2)
if gameExit == True:
pygame.quit()
quit()
'while while gameExit'は疑わしいと思われます。無限ループかもしれない –