method5
03-29-2002, 11:24 AM
trying to get simple collision detection working... basically want to see if one box is on the of the other...
-----
|..__|__
|_|_|...|
...|___|
(dont mind the dots, heh)
the top corners of these are..
box1x
box1y
and
box2x
box2y
and they are sized 32x32
ive been trying something and just cant get it to work and wanted to see if someone could help...
for(int i = box1x; i < box1x+32; i++) {
for(int j = box1y; j < box1y+32; j++) {
if(i >= box2x && i <= box2x+32 && j >= box2y && j <= box2y+32) { cout<< "there is a collision"; }
}
}
doesnt seem to be working...
what i wanted that ot do is do through every pixel of the one and see if its in the other.. any ideas?
[This message has been edited by method5 (edited 03-29-2002).]
-----
|..__|__
|_|_|...|
...|___|
(dont mind the dots, heh)
the top corners of these are..
box1x
box1y
and
box2x
box2y
and they are sized 32x32
ive been trying something and just cant get it to work and wanted to see if someone could help...
for(int i = box1x; i < box1x+32; i++) {
for(int j = box1y; j < box1y+32; j++) {
if(i >= box2x && i <= box2x+32 && j >= box2y && j <= box2y+32) { cout<< "there is a collision"; }
}
}
doesnt seem to be working...
what i wanted that ot do is do through every pixel of the one and see if its in the other.. any ideas?
[This message has been edited by method5 (edited 03-29-2002).]