#7760 - maniac - Tue Jun 24, 2003 8:53 am
I scroll a 1024x1024 map on a 256x256 wraparound bg and check a 32x32 sprite for collisions with the bg.
The problem occurs only when the bg is wrapping, then the collision check checks one row below the row it is supposed to check (when the bg doesn't wrap it works as it's supposed to). The code I use is this:
x = (bkg.x+player.x) >> 3;
y = (bkg.y+player.y) >> 3;
b = (x&31) + ((y-1&31) << 5);
if(collision[b] == 1)
return 1;
Anyone who can see a prob with this code or have some suggestions to solve the wraparound issue?
The problem occurs only when the bg is wrapping, then the collision check checks one row below the row it is supposed to check (when the bg doesn't wrap it works as it's supposed to). The code I use is this:
x = (bkg.x+player.x) >> 3;
y = (bkg.y+player.y) >> 3;
b = (x&31) + ((y-1&31) << 5);
if(collision[b] == 1)
return 1;
Anyone who can see a prob with this code or have some suggestions to solve the wraparound issue?