Ir para conteúdo
Fórum Script Brasil
  • 0

Invalid Syntax python (pygame)


matheus navroski

Pergunta

Eu sou novo no python e me deparei com o seguinte erro: "Invalid syntax" enão faço ideia do que fiz de errado... Alguém poderia me ajudar? Segue as linhas do programa:

>>>  import sys, pygame
        pygame.init()
 
        size = width, height = 320, 240
        speed = [2, 2]
        black = 0, 0, 0
 
        screen = pygame.display.set_mode(size)
 
        ball = pygame.image.load("ball.bmp")
        ballrect = ball.get_rect()
  
        while 1:
                for event in pygame.event.get():
                        if event.type == pygame.QUIT: sys.exit()
  
                ballrect = ballrect.move(speed)
                if ballrect.left < 0 or ballrect.right > width:
                        speed[0] = -speed[0]
                if ballrect.top < 0 or ballrect.bottom > height:
                        speed[1] = -speed[1]
  
                screen.fill(black)
                screen.blit(ball, ballrect)
                pygame.display.flip()

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0
import sys, pygame
pygame.init()

size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ball.bmp")
ballrect = ball.get_rect()

while 1:
        for event in pygame.event.get():
                if event.type == pygame.QUIT: sys.exit()

        ballrect = ballrect.move(speed)
        if ballrect.left < 0 or ballrect.right > width:
                speed[0] = -speed[0]
        if ballrect.top < 0 or ballrect.bottom > height:
                speed[1] = -speed[1]

        screen.fill(black)
        screen.blit(ball, ballrect)
        pygame.display.flip() 

acho que assim funciona

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...