K
K
Klavdea2020-04-25 19:08:05
pygame
Klavdea, 2020-04-25 19:08:05

The program writes a syntax error on line 4 and does not start. Where is the mistake?

import pygame
pygame.init()
screen=pygame.display.set_mode([640,480],0,0)
​screen.fill([255,255,255])
avto=pygame.image.load("car.jpg")#(character loading )
screen.blit(avto,[50, 50])#(display drawing starting at position[50,50])
​running=True
while running:
​for event in pygame.event.get():
​if event.type==pygame.QUIT:
running=False
pygame.quit()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-04-25
@Klavdea

There, not only on the 4th line, there are also on 7,8,9 and probably further. Did you type the code on an old typewriter or copy it from a pdf or djvu curve? My sublime broke from this code). There toli characters in different encodings, roofing felts some other game. Whatever it is, dial the code manually!
Here is the working code:

import pygame

pygame.init()
screen = pygame.display.set_mode([640,480],0,0)
screen.fill([255,255,255])
avto = pygame.image.load('car.jpg')
screen.blit(avto,[50,50])
pygame.display.update()
running = True

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

You also need to call the 'pygame.display.update()' method, otherwise you won't see your car.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question