i have gotten the paddle to ball and the wall collisions working, but i can't get the ball to block collisions working good. I think the prob is because i am usualy moving the ball 5 units at a time. I am trying using a loop so if i move 5 units at a time i test for each 5 but only draw at the end, but this still does not work.
here is some of the code
Code:
for (i =0; i< 6; i++)
{
block_collision_detection();
textprintf(screen, font, 2,
ball.x += ball.x_speed/6;
ball.y += ball.y_speed/6;
}
void block_collision_detection()
{
int x,y;
for (x=0; x<SCRX/BLOCK_W; x++)
{
for (y=0; y<SCRY/BLOCK_H-2; y++)
{
if (map.block[x][y].active && BBCD(ball.bounding_box, map.block[x][y].bounding_box))
{
//find out which side of the block the bounce is on and bounce
if (!block_hit)
{
if (ball.bounding_box.bottom >= map.block[x][y].bounding_box.top && ball.bounding_box.bottom <= map.block[x][y].bounding_box.bottom && ball.bounding_box.left >= map.block[x][y].bounding_box.left && ball.bounding_box.right <= map.block[x][y].bounding_box.right) ball.bounce(TOP, xblip);
else if (ball.bounding_box.top <= map.block[x][y].bounding_box.bottom && ball.bounding_box.top >= map.block[x][y].bounding_box.top && ball.bounding_box.left >= map.block[x][y].bounding_box.left && ball.bounding_box.right <= map.block[x][y].bounding_box.right) ball.bounce(BOTTOM, xblip);
else ball.bounce(LEFT, xblip);
map.block[x][y].del();
block_hit = true;
}
}
}
}
return;
}