   Having problems with bouncing a ball...
  Hi everyone.I'm trying to clone arkanoid for a start. I think it's not that much complex as a game so I thought I'd give it a try. This is not my first attempt on programming but it's kind of my first attempt at trying to face the obstacles for real.I'm trying to keep it simple for now, but there's one thing I need to get done so that the game is at least coherently playable.Bouncing is not exactly the problem actually, what I need is to change the ball's movement direction based on what part of the stick it bounces from. I also don't have a direction variable yet because I'm not yet sure how to deal with it.I've seen a formula to do this once but I can't remember how it was, and I also didn't quite understand it when I saw it. Even though it seemed simple enough.Can anyone help me with it, and to understanding it?(edit)PS: I've just tested colision with blocks and I think I'll need a better collision with them too. And I believe that collision method is what I will have to use on the stick too. Correct me if I'm wrong.Thanks in advance.[Edited by - Master thief on May 27, 2009 11:56:24 AM]
  keep track of the balls velocity as a 2D vector (x,y).  Anytime there is a collision just flip the sign of one of the components.For example, if the ball is moving up and to the right v=(+x,+y).  If it hits the top of the screen, invert the y velocity component to v=(+x,-y).  If you hit the side wall the invert the x component.This is the easiest way to handle it.  You can start getting more fancy by adding damping 0<d<1 to slow down the ball when it hits something, or by modifying both compoents based on where on the user's bat the ball hits.;  I'm trying to figure out how to do that. I'm doing this is in Blitz3d, by the way.This is the main loop from the game so far (only bat and ball). This is mostly what I had done already, I made no changes except for the start variable that allows me to hold the ball on the stick before pressing the space bar.The ball only moves in 45 degrees angles atm...While Not KeyDown(1)Cls   DrawImage img_stick, x, y;add movement to the stickIf KeyDown(203) And x > 40 Thenx = x - 5EndIfIf KeyDown(205) And x < 600 Thenx = x + 5EndIf;If x < 40 Then x = 40;If x > 600 Then x = 600DrawImage img_ball, ballx, bally;wait for shooting the ballIf KeyHit(57) And start = 0 Then   xmov = 3ymov = -3 start = 1EndIf;add movement to the ballIf start = 0 Thenballx = xbally = y - 16Else If start = 1ballx = ballx + xmovbally = bally + ymovEndIf;colision with boundariesIf ballx < 8 Or ballx > 632 Then xmov = -xmovIf bally < 8 Or bally > 472 Then ymov = -ymov;colision with stickIf ImagesCollide(img_ball, ballx, bally,0, img_stick, x, y,0) Then ymov = -ymovWaitTimer(frames)FlipWend[Edited by - Master thief on May 29, 2009 5:09:03 PM]