'How to change the background color in Pygame?
I am creating a game using pygame and I am using rapidtables.com for this work but my game window is still not showing the required color. (It's showing but only when I close my game window). Here is my code-
#Space Invaders
from turtle import Screen, screensize
import pygame
#Intialize the game
pygame.init()
#formation of screen
screen = pygame.display.set_mode((800,600))
#Title
pygame.display.set_caption("Space Invaders")
#Game loop
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
pygame.display.flip()
#RGB, Red, Green and blue
screen.fill((255, 0, 0))
pygame.display.update()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
