Найти - Пользователи
Полная версия: цвет фона в pygame
Начало » Python для новичков » цвет фона в pygame
1
rascally_rabbit
Здравствуйте.

Помогите, пожалуйста, с pygame
Нижеприведенный код работает без ошибок, но цвет фона окна не изменяется.

 import sys
import pygame
def run_game():
    pygame.init()
    screen = pygame.display.set_mode((900, 600))
    pygame.display.set_caption("Alien Invasion")
    bg_color = (230, 230, 230)
    
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
    screen.fill(bg_color)
    pygame.display.flip()
run_game()
Romissevd
 import sys
import pygame
def run_game():
    pygame.init()
    screen = pygame.display.set_mode((900, 600))
    pygame.display.set_caption("Alien Invasion")
    bg_color = (230, 230, 230)
    screen.fill(bg_color)
    pygame.display.flip()
    
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
    
run_game()
Проблема в том, что твоя программа доходит до выполнения цикла и зависает, пока не выполнишь закрыть окно, затем по код выполняется дальше, но ты этого уже не видишь…
rascally_rabbit
Спасибо, все работает!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB