Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //for obj_ball in the collision event with obj_paddle:
- //calculations
- ballSize = bbox_right - bbox_left;
- paddleSize = other.bbox_right - other.bbox_left;
- ballMiddle = bbox_left + ballSize/2;
- paddleMiddle = other.bbox_left + paddleSize/2;
- bounceDistance = abs(ballMiddle-paddleMiddle);
- bounceAngle = bounceDistance/paddleSize;
- //perform bounce
- vspeed *= -1; \\multiply vspeed by -1 (reverse the vertical direction)
- hspeed = speed*bounceAngle;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement