0

First of all I would like to point out that all my values are correct in boxes[5][4] which contains the two x and y values needed for each box. boxes[0][0] and boxes[0][1] are the x and y value for the top left of the rectangle. boxes[0][2] and boxes[0][3] are the x and y vales for the bottom right of the rectangle. This function should see if my ball has hit any of the five boxes. When running my ball just looks like its bouncing off of countless "ghost" boxes and I cannot figure out why. Any help I would be grateful of, and if you need any more code or any more info on the program just ask.

```
void checkbox(){
//check for collision of box one
if (ballx1 >= boxes[0][0] && ballx1 <= boxes[0][2]){
box[0] = 0;
dirx = dirx * -1;
}
else if (bally1 >= boxes[0][1] && bally1 <= boxes[0][3]){
box[0] = 0;
diry = diry * -1;
}
//check for collision of box two
else if (ballx1 >= boxes[1][0] && ballx1 <= boxes[1][2]){
box[1] = 0;
dirx = dirx * -1;
}
else if (bally1 >= boxes[1][1] && bally1 <= boxes[1][3]){
box[1] = 0;
diry = diry * -1;
}
//check for collision of box three
else if (ballx1 >= boxes[2][0] && ballx1 <= boxes[2][2]){
box[2] = 0;
dirx = dirx * -1;
}
else if (bally1 >= boxes[2][1] && bally1 <= boxes[2][3]){
box[2] = 0;
diry = diry * -1;
}
//check for collision of box four
else if (ballx1 >= boxes[3][0] && ballx1 <= boxes[3][2]){
box[3] = 0;
dirx = dirx * -1;
}
else if (bally1 >= boxes[3][1] && bally1 <= boxes[3][3]){
box[3] = 0;
dirx = dirx * -1;
}
//check for collision of box five
else if (ballx1 >= boxes[4][0] && ballx1 <= boxes[4][2]){
box[4] = 0;
dirx = dirx * -1;
}
else if (bally1 >= boxes[4][1] && bally1 <= boxes[4][3]){
box[4] = 0;
dirx = dirx * -1;
}
}
```

*Edited
by noey699*: made a misteak