Hi,

i'm trying to make a breakout game using jedi sdl and delphi. I'm using the supplied SpriteEngine. in my balls collisioncheck procedure i use to following code where middleX and middley Is the balls middle, rect1 is the rectangle for the ball and rect2 the rectangle for the block that's been hit

Code:
 
     MiddleX := rect1.x +(rect1.w div 2);
     MiddleY := Rect1.y +(rect1.h div 2);

     if &#40;MiddleX >= rect2.x&#41; and &#40;MiddleX <= Rect2.x + Rect2.w&#41; then
     begin
      yi &#58;= yi * -1;
      y &#58;= y + yi;
      TBlock&#40;Parentlist&#91;tel&#93;&#41;.IncreaseHits;
     end
     else
     if &#40;MiddleY >= rect2.y&#41; and &#40;MiddleY <= rect2.y + rect2.h&#41;  then
     begin
      xi &#58;= xi * -1;
      x &#58;= x + xi;
      TBlock&#40;parentlist&#91;tel&#93;&#41;.IncreaseHits;
     end
now that works ok but now i need to add some code to see when the ball hits the block at the corners and change the ball in the correct direction. how would i do that. also i'm stuck on something else as well the code for checking the corners may not be done when there are 2 blocks hit at the same time the above code should be enough then (i think).

can someone help me out here, i could upload my code if that'll be easier cause i'm getting nowhere.

a simple demo with a ball hitting a rectangle would help as well as long as it implements hits from the 4 corners of the rectangle and the ball

thanks