Exemplo n.º 1
0
         # level 幾就有幾顆球
         if ball_counter < level:
             launcher.launch_balls(ball_group)
             ball_counter += 1
         else:
             state = "hit"
             first_killed_ball_x = None
     
 elif state == "hit":
     
     # 第一顆球落下的位置會是下一次發射的位置
     if first_killed_ball_x == None:
         for ball in ball_group:
             first_killed_ball_x = ball.get_killed_x()
             if first_killed_ball_x != None:
                 launcher.set_pos_x(first_killed_ball_x)
                 break
     # 所有的球都掉下來了 或 按up
     keys = pygame.key.get_pressed()
     if len(ball_group) == 0 or keys[pygame.K_UP]:
         for ball in ball_group:
             ball.kill()
         state = 'new_block'
         level += 1
 
 elif state == "new_block":
     for i in range(7):
         # 若場面上的方塊大於8個,每一個位子有0.3的機率生成方塊,否則是0.6
         if len(block_group) > 8:
             prob = 0.3
         else: