0

Working on a pong game in CodeSkulptor, and trying to figure out how to make my collisions match with the paddles. The collision happens but inconsistently, and not within the paddle surface:

# determine whether paddle and ball collide
if ball_pos[0] <= PAD_WIDTH + BALL_RADIUS + 2:
    if ball_pos[1] >= paddle2_pos - HALF_PAD_HEIGHT 
       and ball_pos[1] <= paddle2_pos + HALF_PAD_HEIGHT:
        ball_vel[0] = -ball_vel[0] * accel
        ball_vel[1] = ball_vel[1] * accel

The full program so far is here, have only attempted left paddle collision so far: https://py2.codeskulptor.org/#user49_IPKtqi510l_1.py

JoeP
  • 45
  • 8

0 Answers0