My pygame screen is not updating event with pygame.display.update

Viewed 82

My pygame screen is not updating correctly and i am not sure why.

pygame code:

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()

I have look on the internet and found nothing that works, I am new and this is my first pygame. Any help would be appreciated.

1 Answers

Simply change pygame.display.update to pygame.display.update()
pygame.display.update does not call the function. If you want to call the function, use function_name(args).

Related