Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed issue #29

Open
aroary opened this issue Nov 21, 2021 · 0 comments · Fixed by #27
Open

speed issue #29

aroary opened this issue Nov 21, 2021 · 0 comments · Fixed by #27
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@aroary
Copy link
Collaborator

aroary commented Nov 21, 2021

There seems to be a problem with the speed calculations related to #27 .

if ball_position[0] <= 5 + p1_paddle_width + radius / 2 and p1_position - radius / 2 <= ball_position[1] and p1_position + p1_paddle_height + radius / 2 >= ball_position[1] and speed < 0:
    speed *= -1
    if ball_position[1] >= p1_position - radius / 2 and ball_position[1] <= p1_position - radius / 2 + 15 and vertical_speed > 0:
        vertical_speed = vertical_speed * -1 - 1
    elif ball_position[1] <= p1_position + p1_paddle_height + radius / 2 and ball_position[1] >= p1_position + p1_paddle_height + radius / 2 - 15 and vertical_speed < 0:
        vertical_speed = vertical_speed * -1 + 1
    else:
        vertical_speed -= .25
    if audio:
        pygame.mixer.music.play()
if ball_position[0] >= width - 5 - p2_paddle_width - radius / 2 and p2_position - radius / 2 <= ball_position[1] and p2_position + p2_paddle_height + radius / 2 >= ball_position[1] and speed > 0:
    speed *= -1
    if ball_position[1] >= p2_position - radius / 2 and ball_position[1] <= p2_position - radius / 2 + 15 and vertical_speed > 0:
        vertical_speed = vertical_speed * -1 - 1
    elif ball_position[1] <= p2_position + p2_paddle_height + radius / 2 and ball_position[1] >= p2_position + p2_paddle_height + radius / 2 - 15 and vertical_speed < 0:
        vertical_speed = vertical_speed * -1 + 1
    else:
        vertical_speed += .25
    if audio:
        pygame.mixer.music.play()
@aroary aroary added bug Something isn't working help wanted Extra attention is needed question Further information is requested labels Nov 21, 2021
@aroary aroary linked a pull request Nov 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants