Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

the background color of my program is only visable when I close the app icon

I have an app icon open but I can’ see a white background in my application window untill I close the app. What do I do?


import pygame

# Internationalizing Pygame
pygame.init()
# Title and Icon
pygame.display.set_caption("Space Invaders")
icon = pygame.image.load()
pygame.display.set_icon(icon)

# player
playerIMG = pygame.image.load()
playerX = 370
playerY = 30
screen = pygame.display.set_mode((1200, 600))


def player():
    screen.blit(playerIMG, (playerX, playerY))


running = True
while running:  # RGB
    screen.fill((222, 222, 222))

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

player()
pygame.display.update()

I don’t know what to do.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is a matter of Indentation you have to draw the scene and update the display in the application loop:

running = True
while running:  # RGB
    screen.fill((222, 222, 222))

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

# INDENTATION
#-->|
    player()
    pygame.display.update()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading