Answer the question
In order to leave comments, you need to log in
pygame errors in python?
This error pops up: EndentationError: unindent does not much any outer indentation level
import sys
import pygame
def run_game():
#Initializes the game and creates a screen object
pygame.init()
screen = pygame.display.set_mode((1200, 800))
pygame .display.set_caption('Alien Invasion')
bg_color = (230, 230, 230)
while True:
# Monitor keyboard and mouse events.
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# The screen is redrawn on each iteration of the loop
screen.fill(bg_color)
pygame.display.flip()
run_game()
Answer the question
In order to leave comments, you need to log in
You have lost indents in your code, as evidenced by the IndentationError
# Отслеживание событий клавиатуры и мыши.
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# При каждом проходе цикла перерисовывается экран
screen.fill(bg_color)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question