0

I am making a platformer game in pygame but I am not able to change the color of the background of the window. This is my code:-

import pygame
import self as self

pygame.init()

SCREEN_WIDTH = 800
SCREEN_HEIGHT = int(SCREEN_WIDTH * 0.8)

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Platformer')
screen.fill(color = 'Green')

run = True
while run:
    for event in pygame.event.get():
        #quit game
        if event.type == pygame.QUIT:
            run = False
pygame.quit()

3 Answers3

1

Try to provide the color in RGB

# Initialing RGB Color 
color = (255,0, 0)
  
# Changing surface color
screen.fill(color)
0

first you have to make a variable like :

blue = (0, 0, 255)

with Decimal Code (R,G,B) then :

screen.fill(blue)
0x27752357
  • 34
  • 4
0

Try this:

#you allraedy have screen variable in your code
screen.fill(0, 0, 255)#Blue

if you don't know about the RGB colors you can take a look at the colors in the paint windows program, or you can search google, however the code above means a mix of 0 red and 0 green and 100% blue you can mix accourding to this NOTE:i'm not sure if this is the write code to put the RGB code try it and tell me did it work or not.

LORD_M.D
  • 11
  • 1