Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
matheus navroski

Invalid Syntax python (pygame)

Question

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()

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Cloud Computing


  • Forum Statistics

    • Total Topics
      148417
    • Total Posts
      643832
×
×
  • Create New...