def play_game(utility, DISPLAYSURF): fps_clock = pygame.time.Clock() pygame.mixer.music.load("./music/game_theme.mp3") pygame.mixer.music.play(-1, 2.0) player = Bar() ball = Ball() player.draw(DISPLAYSURF) ball.draw(DISPLAYSURF) blocks = draw_blocks(utility, DISPLAYSURF) while True: # main game loop keys = pygame.key.get_pressed() #move bar when right or left arrow is held down or pushed down if (keys[pygame.K_RIGHT]): player.move(DISPLAYSURF, 3) elif (keys[pygame.K_LEFT]): player.move(DISPLAYSURF, -3) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() elif event.type == MOUSEBUTTONUP: print(event.pos) ball.move(DISPLAYSURF, player) draw_blocks2(utility, DISPLAYSURF, blocks) # determine if ball hits a block block_collision = utility.getBallNBlockCollision(ball, blocks) if block_collision: # deduct from that blocks health blocks = block_collision.deductHealth(blocks, ball, player, DISPLAYSURF) if ball.outOfScreen(): player.reduceLives() ball.resetPosition() pygame.display.update() fps_clock.tick(utility.getFPS())