ball_paddle_collision_flag = ball.ball_paddle_collision(pd) ball.ball_wall_collision() score = ball.ball_brick_collision(bricks=BRICKS, canvas=CANVAS, powerups=POWERUPS, score=score) check_powerup_bricks() check_ball_grab() check_game_over() check_game_win() brick_fall(ball_paddle_collision_flag) if ball.over(CANVAS): reset() pd.display(CANVAS) ball.display(CANVAS) print_canvas() # TAKING INPUT key_press = ip.get_parsed_input(timeout=0.07) if key_press == "d": pd.move_paddle(CANVAS, 4) if attached: ball.move(CANVAS, vel_x=4, attached=True) elif key_press == "a": pd.move_paddle(CANVAS, -4) if attached: ball.move(CANVAS, vel_x=-4, attached=True) if not attached:
# # main # WIDTH = 128 HEIGHT = 64 score = Score(WIDTH, HEIGHT) ball = Ball(WIDTH, HEIGHT, score) paddle_r = Paddle(WIDTH, HEIGHT) paddle_l = Paddle(WIDTH, HEIGHT, True) game_disp = set_pygame_keys(GameDisplay(WIDTH, HEIGHT), paddle_l, paddle_r) # # main loop # while 1: time.sleep(.05) if ball_hit_paddle(paddle_l, ball) or ball_hit_paddle(paddle_r, ball): ball.x_bounce() ball.move() paddle_l.move() paddle_r.move() game_disp.check_keys() game_disp.translate_to_pygame( score.display( ball.display( paddle_l.display( paddle_r.display(make_new_display(WIDTH, HEIGHT))))))