EDIT- This is my implementation of the pseudo code. In the log, 'hit true' is never thrown but i probably got the vector->separate x/y values and the for for loops wrong.
public boolean gethit(obstacle second){ int ox = second'hit trying' is.obx; int oy = second Its not working as intended.oby; int oh = second.obh; int ow = second.obw;
public boolean gethit(obstacle second){
int AABBxpx, AABBypy, AABBwph,pw;
AABBh;
Bitmap sprite1 = rotatedbm;
Bitmap sprite2 = second.getgfx();
px = playerx;
py = playery;
ph = sprite1.getHeight();
pw = sprite1.getWidth();
int alpha1;ox = second.obx;
int alpha2;oy = second.oby;
int oh = second.obh;
AABBw int ow = playerwsecond.obw;
-
int [] AABB1bl = {px, py+ph};
int [] AABB1tr = {px+pw, py};
int [] AABB2bl = {ox, oy+oh};
int [] AABB2tr = {ox+ow, oy};
AABB2bl[0] -= playerx;AABB1bl[0];
AABBh AABB2bl[1] -= playerhAABB1bl[1];
AABB2tr[0] -= oyAABB1bl[0];
AABB2tr[1] -= playery;AABB1bl[1];
AABBx
AABB1tr[0] -= playerxAABB1bl[0];
+ playerw AABB1tr[1] -= AABBw;AABB1bl[1];
AABBy
AABB1bl[0] -= playeryAABB1bl[0];
+ playery AABB1bl[1] -= AABBh;AABB1bl[1];
int start_x = AABB2bl[0];
int start_y = AABB2tr[1];
int end_x = AABB1tr[0];
int end_y = AABB1bl[1];
int ALPHAMASK = 0xFF<<24; // assuming colors are represented as 0xAARRBBGG
Bitmap sprite1 = rotatedbm; int alpha1;
Bitmap sprite2 = second int alpha2;
Log.getgfxi("hit", "trying");
for(int x = 0;start_x; x < Math.abs(AABBw);end_x; x++)
for(int y = 0;start_y; y < Math.abs(AABBh);end_y; y++) {
alpha1 = sprite1.getPixel(playerw-AABBw+xx , playery-AABBh+yy*sprite1.getWidth()) & ALPHAMASK;
alpha2 = sprite2.getPixel(x + AABB2bl[0], y(y+AABB2tr[1])*sprite2.getWidth()) & ALPHAMASK;
if(alpha1 != 0 && alpha2 != 0) {
Log.i("hit", "true");
return true; // you'd probably wish to return after a colliding pixel has been found
}
}
return false;
}
}