# 按叉叉會結束程式 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if state == 'aim': keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: launcher.tilt_left() elif keys[pygame.K_RIGHT]: launcher.tilt_right() elif keys[pygame.K_SPACE]: launcher.launch_balls(ball_group) # 準備下一個state state = 'launch' frame_counter = 0 ball_counter = 1 elif state == 'launch': frame_counter += 1 # 每四幀畫面發射一顆球 if frame_counter % 4 == 0: # level 幾就有幾顆球 if ball_counter < level: launcher.launch_balls(ball_group)