Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

collision : a box and a ball

Hi, I want to make an arcanoid game. But, i have a problem with the collision algorithm. If there is a ball that overlap with a box, how can i decide the direction of the ball for the next move ? (note : the ball can hit a box from it's left or right)

Comments

  • Josh CodeJosh Code Member Posts: 675
    : Hi, I want to make an arcanoid game. But, i have a problem with the collision algorithm. If there is a ball that overlap with a box, how can i decide the direction of the ball for the next move ? (note : the ball can hit a box from it's left or right)
    :

    How is the direction of the ball's motion defined?

    If you have variables to store the change in x and the change in y for each interval of motion, the bouce is easy. If the ball is coming from the right or left, just change the sign of the change in x. If the ball is coming from the top or bottom, change the sign of the change in y.

    For example, let's say the ball is coming from the right so the x change = -5 and y change = 1, after hitting the left side of the box, the x change becomes +5. The y change stays the same.





  • brajabasibrajabasi Member Posts: 1
    hi sunanda,
    i don't know where r u from,
    but u should follow the book yashwant kanetkar,graphics in c.also follow the bricks game,u can easily get,if not then mail me again.
    my mail id is brajabasipadhy@yahoo.co.in,urs faithfully brajabasi




    : Hi, I want to make an arcanoid game. But, i have a problem with the collision algorithm. If there is a ball that overlap with a box, how can i decide the direction of the ball for the next move ? (note : the ball can hit a box from it's left or right)
    :
    :

Sign In or Register to comment.