for whatever reason I can't figure this out
I'm using some code from gamedev for 2d pixel perfect collision detection, it looks like this now
The problem is I can't figure out how to convert z and y in the for loops into actual x's and y's for the two SDL surfaces I'm colliding (ship and bullet)Code:bool CollideYou(int index) { int left1, left2; int right1, right2; int top1, top2; int bottom1, bottom2; left1 = BulletsE[index].x; left2 = You.x; right1 = BulletsE[index].x + 5; right2 = You.x + 99; top1 = BulletsE[index].y; top2 = You.y; bottom1 = BulletsE[index].y + 20; bottom2 = You.y + 75; if (bottom1 < top2) return false; if (top1 > bottom2) return false; if (right1 < left2) return false; if (left1 > right2) return false; int over_bottom, over_top, over_right, over_left; if (bottom1 > bottom2) over_bottom = bottom2; else over_bottom = bottom1; if (top1 < top2) over_top = top2; else over_top = top1; if (right1 > right2) over_right = right2; else over_right = right1; if (left1 < left2) over_left = left2; else over_left = left1; for (int z = over_bottom; z <= over_top; z++) { for (int y = over_left; y <= over_right; y++) { } } return false; }
Thanks,
MC



LinkBack URL
About LinkBacks



CornedBee