我的pygame屏幕没有更新pygame.display.update事件



我的pygame屏幕没有正确更新,我不知道为什么。

pygame代码:

import pygame
import os 
import random
import time
pygame.init()
width = 750
height = 750
win = pygame.display.set_mode((width, height))
pygame.display.set_caption('Space attack')
bg_size = 750, 750
bg = pygame.image.load("/home/pi/Pygames/Space_attack/background-black.png")
image = pygame.transform.scale(bg, bg_size)
#ships
r_ship= pygame.image.load('/home/pi/Pygames/Space_attack/pixel_ship_red_small.png')
g_ship= pygame.image.load('/home/pi/Pygames/Space_attack/pixel_ship_green_small.png')
b_ship= pygame.image.load('/home/pi/Pygames/Space_attack/pixel_ship_blue_small.png')
#player
player = pygame.image.load('/home/pi/Pygames/Space_attack/pixel_ship_yellow.png')
#laser
r_laser = pygame.image.load('/home/pi/Pygames/Space_attack/pixel_laser_red.png')
b_laser = pygame.image.load('/home/pi/Pygames/Space_attack/pixel_laser_blue.png')
g_laser = pygame.image.load('/home/pi/Pygames/Space_attack/pixel_laser_green.png')
p_laser = pygame.image.load('/home/pi/Pygames/Space_attack/pixel_laser_yellow.png')
#game
def main():
run = True
fps = 30
clock = pygame.time.Clock()

def redraw_window():
win.blit(bg, (0,0))

pygame.display.update

while run:
clock.tick(fps)
redraw_window()

for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False

main()

我在互联网上看,发现没有任何工作,我是新的,这是我的第一个pygame。如有任何帮助,不胜感激。

只需将pygame.display.update更改为pygame.display.update()
pygame.display.update调用函数。如果要调用该函数,请使用function_name(args)

最新更新