为什么我在Pygame中编码Pong时无法显示球?

时间:2015-10-05 01:02:49

标签: python pygame

我是编码Pygame的新手。我的第一个任务是编写error。但是,我发现两个球无法在屏幕上显示。我不知道原因。我会提供我的代码。谢谢!此外,最后一行有error。但是,我只是从Pygame文档中复制,我不知道为什么它存在import pygame,sys,time # Open a brand-new window pygame.init() Screen_size = (500,400) Title = ('Pong') Frame_Delay = 0.01 Surface= pygame.display.set_mode(Screen_size,0,0) pygame.display.set_caption(Title) # Set up white color for drawing balls white=pygame.Color('white') # Now, we start to draw two balls pos1=(100,200) pos2=(400,200) rad=50 ball1=pygame.draw.circle=(Surface,white,pos1,rad,0) ball2=pygame.draw.circle=(Surface,white,pos2,rad,0) pygame.display.update() # Now, define speed speed=[2,2] # Now, we define a loop while ball1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit()

Traceback (most recent call last):
  File "/tmp/guest-54jjJ1/Desktop/pong.py", line 24, in <module>
    if event.type == pygame.QUIT: sys.exit()
builtins.SystemExit:

语法错误将显示在

下面
on line 12:
NBATeam heat= new NBATeam("Heats", numberOfPlayers);

3 个答案:

答案 0 :(得分:1)

试试这个

WHERE tp5.[Cc EV PS] Is Not Null ->
WHERE tp5.[Cc EV PS] Is Not Null and tp5.[GICS Sector] = t1.[GICS Sector]


WHERE tp3.[Cc EV PS] Is Not Null ->
WHERE tp3.[Cc EV PS] Is Not Null and tp3.[GICS Sector] = t1.[GICS Sector]

在许多情况下,移动while ball1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() 会有所帮助。

答案 1 :(得分:1)

这是你的问题:

ball1=pygame.draw.circle=(Surface,white,pos1,rad,0)
ball2=pygame.draw.circle=(Surface,white,pos2,rad,0)

你不应该将函数=设置为元组。您应该像这样致电draw.circle()

ball1 = pygame.draw.circle(Surface, white, pos1, rad, 0)
ball2 = pygame.draw.circle(Surface, white, pos2, rad, 0)

顺便说一句,调用变量Surface非常糟糕。这是pygame

中类的名称

答案 2 :(得分:0)

缩进,交配......

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