Окно Pygame не открывается через python лаунчер - PullRequest
1 голос
/ 07 апреля 2020

'' 'code' '' #! / Library / Frameworks / Python .framework / Versions / 3.8 / bin / python3 импорт pygame из pygame.locals import *

pygame.init()

screen = pygame.display.set_mode((800,800))
pygame.display.set_caption("Space Invaders")


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

Ответы [ 2 ]

0 голосов
/ 18 апреля 2020

Это должно работать.

import pygame
pygame.init()

screen = pygame.display.set_mode((800,800))
pygame.display.set_caption("Space Invaders")


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

    pygame.display.update()

Вы должны были импортировать pygame, изменить if event.type == QUIT: if event.type == pygame.QUIT: и обновить экран с помощью pygame.display.update()

0 голосов
/ 11 апреля 2020

Попробуйте это:

pygame.init()

screen = pygame.display.set_mode((800,800))
pygame.display.set_caption("Space Invaders")


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

    screen.fill((0, 0, 0))
    pygame.display.update()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...