W
W
Webik20182017-10-01 14:09:49
Python
Webik2018, 2017-10-01 14:09:49

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

1 answer(s)
T
Twelfth Doctor, 2017-10-01
@verdex

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)

It is also not clear, during the passage of which particular cycle, the screen is redrawn for you - while or for?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question