Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def moveBall():
- if ball['y'] > (COURT_HEIGHT - 25) and ball['x'] <= (computerPaddle.right + ball['radius']) and ball['x'] >= (computerPaddle.left - ball['radius']):
- ball['speed'] += 1
- if ball['dir'] == DOWNRIGHT:
- ball['dir'] = UPRIGHT
- if ball['dir'] == DOWNLEFT:
- ball['dir'] = UPLEFT
- elif ball['y'] > COURT_HEIGHT:
- score['player'] += 1
- newRound()
- if ball['y'] < 25 and ball['x'] <= (playerPaddle.right + ball['radius']) and ball['x'] >= (playerPaddle.left - ball['radius']):
- ball['speed'] += 1
- if ball['dir'] == UPRIGHT:
- ball['dir'] = DOWNRIGHT
- if ball['dir'] == UPLEFT:
- ball['dir'] = DOWNLEFT
- elif ball['y'] < 0:
- score['computer'] += 1
- newRound()
- if ball['x'] > COURT_WIDTH - ball['radius']:
- if ball['dir'] == UPRIGHT:
- ball['dir'] = UPLEFT
- if ball['dir'] == DOWNRIGHT:
- ball['dir'] = DOWNLEFT
- if ball['x'] < ball['radius']:
- if ball['dir'] == UPLEFT:
- ball['dir'] = UPRIGHT
- if ball['dir'] == DOWNLEFT:
- ball['dir'] = DOWNRIGHT
- if ball['dir'] == UPLEFT:
- ball['x'] -= ball['speed']
- ball['y'] -= ball['speed']
- if ball['dir'] == UPRIGHT:
- ball['y'] -= ball['speed']
- ball['x'] += ball['speed']
- if ball['dir'] == DOWNLEFT:
- ball['y'] += ball['speed']
- ball['x'] -= ball['speed']
- if ball['dir'] == DOWNRIGHT:
- ball['y'] += ball['speed']
- ball['x'] += ball['speed']
- #print(ballX, ballY)
- pygame.draw.circle(windowSurface, WHITE, (ball['x'], ball['y']), ball['radius'], 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement