# A ball hits another ball

**URL:** <https://forum.kirupa.com/t/a-ball-hits-another-ball/1875>\
**Category:** Uncategorized\
**Created:** [May 7, 2002, 5:38am UTC](https://forum.kirupa.com/t/a-ball-hits-another-ball/1875 "2002-05-07T05:38:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 7, 2002, 5:38am UTC](https://forum.kirupa.com/t/a-ball-hits-another-ball/1875/1 "2002-05-07T05:38:58Z")

</div>

i have started making a small game, i have one ball that you control woth your mouse (the player), and one ball that is a ball (the volleyball)…

when the volleyball intersects with the player the volleyball should change direction, if it the volleyball hits the player in the middle (player\_x - ball\_x = 0) there’s no problem, i just change the y-movement value to a negative value. but if the ball hits a bit to the right or a bit to the left, the volleyball should change direction… how?

i tried to do like this:

ball\_y\_mov = Number(ball\_speed \* -1);  
ball\_x\_mov = Number(ball\_x - player\_x);

but then the speed of the ball is VERY fast if it hits far to the left or right…

/PUT440
